Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-26 Thread Thiago Macieira
On segunda-feira, 26 de setembro de 2016 09:57:27 PDT Jędrzej Nowacki wrote: > No. I think we should avoid it, there are to many side effects of such > behavior change. Ok, I will restore the original patch that keeps the fuzzy comparison, just skips it for NaN and infinite. -- Thiago Macieira

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-26 Thread Edward Welbourne
On Fri, Sep 23, 2016 at 09:56:30AM +, Edward Welbourne wrote: >> Indeed; having all values of some type equivalent is worse (for the "has >> my value changed" test you illustrate, at least) than having a value not >> equal to itself (which triggers a "changed" event for a non-change). In >>

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-26 Thread Olivier Goffart
On Freitag, 23. September 2016 19:45:18 CEST André Pönitz wrote: > On Fri, Sep 23, 2016 at 11:22:08AM +0200, Olivier Goffart wrote: > > > There is not much of a choice. An equivalence relation is reflexive, > > > i.e. at least Foo(a) == Foo(a) must be true. Lacking the ability > > > to compare

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-26 Thread Olivier Goffart
On Montag, 26. September 2016 09:55:13 CEST Jędrzej Nowacki wrote: > On fredag 23. september 2016 11.22.08 CEST Olivier Goffart wrote: > > template > > auto registerEqualityOperator() > > > > -> decltype(std::declval() == std::declval()) > > I have tried it already. Sadly it

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-26 Thread Jędrzej Nowacki
On mandag 19. september 2016 09.20.48 CEST Thiago Macieira wrote: > This code was there in Qt 5.0, so I kept it when I refactored the numeric > comparisons. Now, dealing with QTBUG-56073, I'm wondering if it should be > there in the first place. > > Should we do fuzzy comparisns in QVariant? > >

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-26 Thread Jędrzej Nowacki
On fredag 23. september 2016 11.22.08 CEST Olivier Goffart wrote: > template > auto registerEqualityOperator() > -> decltype(std::declval() == std::declval()) I have tried it already. Sadly it breaks terribly in case of private/protected operators. It doesn't solve the problem,

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-23 Thread Sune Vuorela
On 2016-09-23, André Pönitz wrote: > That gives already "surprising" behaviour if fed with QChar('a') and > QString("a") in a row. > > And it is "surprising" to a degree that I'd call it buggy. Then try feeding it boolean's and strings. QQmlPropertyMap map;

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-23 Thread André Pönitz
On Fri, Sep 23, 2016 at 09:56:30AM +, Edward Welbourne wrote: > Indeed; having all values of some type equivalent is worse (for the "has > my value changed" test you illustrate, at least) than having a value not > equal to itself (which triggers a "changed" event for a non-change). In > fact

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-23 Thread André Pönitz
On Fri, Sep 23, 2016 at 11:22:08AM +0200, Olivier Goffart wrote: > > There is not much of a choice. An equivalence relation is reflexive, > > i.e. at least Foo(a) == Foo(a) must be true. Lacking the ability > > to compare Foos, treating them all equal at least doesn't break the > > relation. > >

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-23 Thread Matthew Woehlke
On 2016-09-22 16:58, André Pönitz wrote: > There is not much of a choice. An equivalence relation is reflexive, > i.e. at least Foo(a) == Foo(a) must be true. JFTR... auto nan = qNaN(); assert(nan != nan); // okay assert(!(nan == nan)); // okay -- Matthew

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-23 Thread Edward Welbourne
Olivier Goffart > What use case did you have in mind where a reflexive relation is any usefull? Well, having x == x for all x is generally considered a useful property of equality. That's all "reflexive" is saying. > There is the case of the key of a QHash or in a QSet, but even then i'm not >

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-23 Thread Olivier Goffart
On Donnerstag, 22. September 2016 22:58:09 CEST André Pönitz wrote: > On Thu, Sep 22, 2016 at 06:04:58AM +0200, Mathias Hasselmann wrote: > > Am 22.09.2016 um 00:58 schrieb André Pönitz: > > >On Wed, Sep 21, 2016 at 08:57:01AM +0200, Olivier Goffart wrote: > > >>>No, it's not. It's changing

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-22 Thread André Pönitz
On Thu, Sep 22, 2016 at 06:04:58AM +0200, Mathias Hasselmann wrote: > Am 22.09.2016 um 00:58 schrieb André Pönitz: > >On Wed, Sep 21, 2016 at 08:57:01AM +0200, Olivier Goffart wrote: > >>>No, it's not. It's changing undefined behavior into defined > >>>behavior. > >> > >>But in many case, we want

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Thiago Macieira
On quarta-feira, 21 de setembro de 2016 12:00:15 PDT Marc Mutz wrote: > We have a handful of classes in Qt which have a > 'reserved' field that doesn't get initialized (so it better should be named > 'unusable') That depends on whether the copy constructors and destructor are inline or not. --

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Mathias Hasselmann
Am 22.09.2016 um 00:58 schrieb André Pönitz: On Wed, Sep 21, 2016 at 08:57:01AM +0200, Olivier Goffart wrote: No, it's not. It's changing undefined behavior into defined behavior. But in many case, we want to put something in a QVariant, and we never compare this variant. Forbidding types

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Mathias Hasselmann
Am 21.09.2016 um 12:00 schrieb Marc Mutz: On Wednesday 21 September 2016 11:42:41 Mathias Hasselmann wrote: No matter what order I use for config and value, the compiler will pad and -Wpadded will complain. How am I supposed to fix this? This solutions that come to my mind all are ugly, but

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread André Pönitz
On Wed, Sep 21, 2016 at 08:57:01AM +0200, Olivier Goffart wrote: > > No, it's not. It's changing undefined behavior into defined > > behavior. > > But in many case, we want to put something in a QVariant, and we > never compare this variant. Forbidding types that do not have an > operator== to

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Marc Mutz
On Wednesday 21 September 2016 11:42:41 Mathias Hasselmann wrote: > Am 21.09.2016 um 09:52 schrieb Marc Mutz: > > On Wednesday 21 September 2016 09:23:35 Mathias Hasselmann wrote: > >> Maybe some clever use of type traits can tell us if your structs contain > >> alignment wholes? > > > >

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Mathias Hasselmann
Am 21.09.2016 um 09:52 schrieb Marc Mutz: On Wednesday 21 September 2016 09:23:35 Mathias Hasselmann wrote: Maybe some clever use of type traits can tell us if your structs contain alignment wholes? -Werror=padded :) Yes, but how is it supposed to help? Let me show a real world example:

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Marc Mutz
On Wednesday 21 September 2016 09:23:35 Mathias Hasselmann wrote: > Maybe some clever use of type traits can tell us if your structs contain > alignment wholes? -Werror=padded :) -- Marc Mutz | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Mathias Hasselmann
Am 21.09.2016 um 08:57 schrieb Olivier Goffart: On Mittwoch, 21. September 2016 08:01:22 CEST Mathias Hasselmann wrote: As much as I'd like to debug this code now to prove me right, I sadly have deadlines to meet this week. So I have to behave myself to not dig up the code right now. Maybe

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Olivier Goffart
On Mittwoch, 21. September 2016 08:01:22 CEST Mathias Hasselmann wrote: > Am 20.09.2016 um 12:44 schrieb Olivier Goffart: > > On Dienstag, 20. September 2016 12:21:11 CEST Mathias Hasselmann wrote: > >> Am 19.09.2016 um 23:27 schrieb Olivier Goffart: > >>> We really cannot have a qHash for

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-21 Thread Mathias Hasselmann
Am 20.09.2016 um 12:44 schrieb Olivier Goffart: On Dienstag, 20. September 2016 12:21:11 CEST Mathias Hasselmann wrote: Am 19.09.2016 um 23:27 schrieb Olivier Goffart: We really cannot have a qHash for QVariant anyway, because that would imply that ALL QVariant can be hashed, and compared.

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-20 Thread Thiago Macieira
On quarta-feira, 21 de setembro de 2016 03:56:31 PDT Kevin Kofler wrote: > Thiago Macieira wrote: > > And I will reject any patch that adds more complexity in qFuzzyCompare for > > a 0.01% corner-case. Instead, we should document that it only works for > > finite numbers far enough away from zero.

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-20 Thread Kevin Kofler
Thiago Macieira wrote: > And I will reject any patch that adds more complexity in qFuzzyCompare for > a 0.01% corner-case. Instead, we should document that it only works for > finite numbers far enough away from zero. If your number can be infinite > or NaN or zero, you have to find something

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-20 Thread Thiago Macieira
On terça-feira, 20 de setembro de 2016 11:29:32 PDT Olivier Goffart wrote: > > Is such a behavior change really acceptable for 5.8? I think it can break > > applications that were relying on the current behavior in pretty bad, hard > > to debug ways (random bugs based on rounding errors). > > I

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-20 Thread Marc Mutz
On Tuesday 20 September 2016 12:44:04 Olivier Goffart wrote: > > It is easy to forget registering comparator functions and currently Qt > > doesn't help in debugging such issues. So I wonder if QVariant should > > forbid comparison of custom types without having a comparator function > >

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-20 Thread Olivier Goffart
On Dienstag, 20. September 2016 12:21:11 CEST Mathias Hasselmann wrote: > Am 19.09.2016 um 23:27 schrieb Olivier Goffart: > > We really cannot have a qHash for QVariant anyway, because that would > > imply > > that ALL QVariant can be hashed, and compared. Which is not the case. Most > > custom

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-20 Thread Mathias Hasselmann
Am 19.09.2016 um 23:27 schrieb Olivier Goffart: We really cannot have a qHash for QVariant anyway, because that would imply that ALL QVariant can be hashed, and compared. Which is not the case. Most custom types don't even register comparator function. Which actually is quite a serious

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-20 Thread Olivier Goffart
On Dienstag, 20. September 2016 03:08:42 CEST Kevin Kofler wrote: > 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. > > Is such a behavior change really acceptable for 5.8? I think it can break

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-20 Thread Marc Mutz
On Monday 19 September 2016 23:27:52 Olivier Goffart wrote: > On Montag, 19. September 2016 18:48:10 CEST Marc Mutz wrote: > > On Monday 19 September 2016 18:20:48 Thiago Macieira wrote: > > > Should we do fuzzy comparisns in QVariant? > > > > If you talk about op==, then using fuzzy compare is a

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread Kevin Kofler
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. Is such a behavior change really acceptable for 5.8? I think it can break applications that were relying on the current behavior in pretty bad, hard

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread Allan Sandfeld Jensen
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

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread Olivier Goffart
On Montag, 19. September 2016 18:48:10 CEST Marc Mutz wrote: > On Monday 19 September 2016 18:20:48 Thiago Macieira wrote: > > Should we do fuzzy comparisns in QVariant? > > If you talk about op==, then using fuzzy compare is a definite no-no, > because it makes it impossible to define a hash

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread Thiago Macieira
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.

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread André Pönitz
On Mon, Sep 19, 2016 at 11:10:51AM -0700, Thiago Macieira wrote: > On segunda-feira, 19 de setembro de 2016 19:47:12 PDT André Pönitz wrote: > > On Mon, Sep 19, 2016 at 09:20:48AM -0700, Thiago Macieira wrote: > > > This code was there in Qt 5.0, so I kept it when I refactored the numeric > > >

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread Thiago Macieira
On segunda-feira, 19 de setembro de 2016 19:47:12 PDT André Pönitz wrote: > On Mon, Sep 19, 2016 at 09:20:48AM -0700, Thiago Macieira wrote: > > This code was there in Qt 5.0, so I kept it when I refactored the numeric > > comparisons. Now, dealing with QTBUG-56073, I'm wondering if it should be >

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread André Pönitz
On Mon, Sep 19, 2016 at 06:48:10PM +0200, Marc Mutz wrote: > Fuzzy comparision should be performed with a named function, qFuzzyCompare, > and _only_ with that function. +1. > We need to fix other classes for Qt 6, too (e.g. Q(Size|Point|Line)F. +1. > That said, a qFuzzyCompare(QVariant,

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread André Pönitz
On Mon, Sep 19, 2016 at 09:20:48AM -0700, Thiago Macieira wrote: > This code was there in Qt 5.0, so I kept it when I refactored the numeric > comparisons. Now, dealing with QTBUG-56073, I'm wondering if it should be > there in the first place. > > Should we do fuzzy comparisns in QVariant?

Re: [Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread Marc Mutz
On Monday 19 September 2016 18:20:48 Thiago Macieira wrote: > Should we do fuzzy comparisns in QVariant? If you talk about op==, then using fuzzy compare is a definite no-no, because it makes it impossible to define a hash function. Fuzzy comparision should be performed with a named function,

[Development] Should QVariant be doing fuzzy comparisons on doubles?

2016-09-19 Thread Thiago Macieira
This code was there in Qt 5.0, so I kept it when I refactored the numeric comparisons. Now, dealing with QTBUG-56073, I'm wondering if it should be there in the first place. Should we do fuzzy comparisns in QVariant? Note that the fuzzy comparisons are always performed in qreal precision