--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Compares this instance to a specified Boolean object and returns an integer that indicates their relationship to one another.
A Boolean object to compare to this instance.
Return Value | Condition |
---|---|
Less than zero | This instance is false and value is true. |
Zero | This instance and value are equal (either both are true or both are false). |
Greater than zero | This instance is true and value is false. |
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
public int CompareTo(Object obj)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
> You can create one (and if it's just for having some form of record of the request), but I will close it as "notPlanned".What's the point to open an issue if it gets immediately closed as not planned?
> I don't see how one can compare booleans in a meaningful way.The same case can be made for other types - e.g. Strings. For some languages (including English) result can be interpreted as alphabetical sorting order,For others - not. So String comparison is generally not meaningful either. We need it nonetheless for technical reasons (related to SEARCH, where "order" is used as a device to implement efficient algo).
It's a matter of convenience. Convenience beats (almost) everything, that's why we have booleans comparable in java, C# and elsewhere, regardless of "meaning".
Now everyone needs to specialcase bools in complex keys. Problem is created for no reason IMO.P.S. Poincare has written a lot about the role of convenience in forming our ideasE.g.~~~The two propositions: "The earth turns round" and "it is more convenient to suppose the earth turns round" have the same meaning; there is nothing more in the one than in the other.
~~~If I don't succeed in convincing you, maybe Poincare will? :-)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Thanks for the reply.
But I am sorry for not understanding the meaning of your example.
Is this the theory of Florian ?
What I think:
-
Define an order for false and true. Natural or not, who cares ?
Everything in computing is stored as a sequence of bits (numbers) and therefore has a "natural" or "technical" or whatever order.
-
False is like 0. And true is like 1.
Where is the problem ?
Maybe your example demonstrated it but I do not understand it.
On Fri, Aug 30, 2013 at 10:29 AM, Gen <gp78...@gmail.com> wrote:
Thanks for the reply.
But I am sorry for not understanding the meaning of your example.
Is this the theory of Florian ?
What I think:
-
Define an order for false and true. Natural or not, who cares ?Well, I care :)When we put a "compareTo" method on a class, it's because we think the objects have a natural ordering, one that is obviously the one you want in almost all cases.You can order *anything* by using a suitable Comparator. Classes don't need to be Comparable, and most aren't. Those that are Comparable have some intrinsic notion of order that is both common and useful and compatible with equality. You often have to order numbers by magnitude, and magnitude is a natural ordering of numbers, so we made numbers Comparable by their magnitude.A DateTime doesn't have an intrinsic ordering because it have multiple dimensions: There is the actual date/time and there is the timezone. We could have chosen to order them by their corresponding UTC moment, but that would disagree with equals, so it's not what we consider a natural order.You can still use comparators to compare DateTime objects in any way you want.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
@Florian: as I noted earlier, difficulties in DateTime all arise from wrong definition of the class, which tries to be too many things at once: it denotes moment in time AND the its REPRESENTATION in different timezones.
It's like we would incorporate String representation into integer, and prove (easily) that ints cannot be compared at all: because 9<10 as ints, but "10"<"9" as strings, and we have intractable problem, so let's define compareTo one way, > another way, and on top of that introduce isLesserThan, isGreaterThan, etc, This is what you did in DateTime, and no amount of clever reasoning will be enough to explain that. But somehow, you are reluctant to introduce "Instant" and split DateTime two notions, so the problem won't go away anytime soon.Do you at least FEEL how confusing it is?
BTW, example with doubles doesn't justify much. The reason it's complicated with doubles is related to special values NaN, +/-0, +/- infinity. There's no special values in dates, so the analogy looks artificial..As for practical reasons to compare booleans, there ARE practcical reasons, as I noted in the opening salvo from this thread.Booleans can be part of complex keys, e.g. we have complex key [ String, int, bool ]. How do you write compareTo function for complex keys of GENERAL composition, e.g. to implement binary search? You want to do it generically, but it won't work BECAUSE your booleans are not comparable. So generic implementation should have special case: if (type==boolean) doOneThing else doAnotherThat;s where I encountered a problem in the first place. This make things ugly.
@Lasse: I don't want to disillusion, but your idea of how DateTime is defined is simplistic. You have to really (physically) open the definition to see what it is.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
On Fri, Aug 30, 2013 at 12:35 PM, <dangli...@gmail.com> wrote:
>> Or false is like 0x404012454 and true is like 0x40401245c. Or the other way around. Or something.Let me disagree with you. Boolean is a data type that having two values. Usually these values are true and false.
For some reason it is enough just one bit to encode these values.
Unfortunately, your example is not obvious by the considerations of reasonableness.
More reasonable example may looks like: false is like 0 and true is like 1 (in bits).Yes. For C programmers (and often other languages) there is an agreement that false has an implicit value of 0, and true of 1. (Try 0 == false in JavaScript).
--This is a historical artifact. One could equally implement false as -1 (for example). In practice true and false are frequently implemented as pointers to some object (at least in JS or Dart). As such the 0, 1 distinction doesn't have any meaning anymore.Given that we don't see practical reasons to call compareTo on booleans we won't make booleans Comparable.--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
--
Give a man a fire and he's warm for the whole day,
but set fire to him and he's warm for the rest of his life. - Terry PratchettFor other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.