[Development] Should QVariant be doing fuzzy comparisons on doubles?
Allan Sandfeld Jensen
kde at carewolf.com
Tue Sep 20 00:08:08 CEST 2016
On Monday 19 September 2016, Thiago Macieira wrote:
> On segunda-feira, 19 de setembro de 2016 21:21:01 PDT André Pönitz wrote:
> > On Mon, Sep 19, 2016 at 11:10:51AM -0700, Thiago Macieira wrote:
> > > Since this is a P3 and 5.8 hasn't been released, I will push the
> > > behaviour change to 5.8 and drop the fuzzy comparison.
>
> https://codereview.qt-project.org/171452
>
> > > > QVariant should not expose any numeric or conversion functionality
> > > > and *only* be used to store and retrieve data. Comparison/Ordering
> > > > should only be used and only be available to the degree needed to
> > > > fullfil basic container requirements. Everything else has bitten in
> > > > the past, and will necessarily continue to do so, and adding more
> > > > conceptually *wrong* features only digs deeper holes.
> > >
> > > That I can't do.
> >
> > That is understood.
> >
> > I am not asking to remove existing functionality, just to not to add
> > "convenience" like
> >
> > QVariant v1 = char('a');
> > QVariant v2 = QChar('a');
> > QVariant v3 = QString("a");
> > assert(v1 == v2 && v2 == v3 && v1 != v3);
>
> It may already be too late.
It is, I am pretty sure we can't fix associativity, but another example is
that qvariant equality is not even commutative right now, in the example
above v2 == v3, but v3 != v2
I had this patch for it two years ago:
https://codereview.qt-project.org/#/c/92850
`Allan
More information about the Development
mailing list