My point exactly.

It's not the existence of primitives, but the broken behavior of == 
operator.

Even back in those days, I remember, how some languages had === operator 
for comparing instances (i.e. pointers to an object), allowing == operator 
to behave in a most intuitive manner, while still giving rather simple 
method for testing object identity.

teisipäev, 13. märts 2012 1:28.26 UTC+2 kirjutas Ricky Clarkson:
>
> Incidentally, the presence of primitives is not the problematic part of 
> the bug that started this thread, but the useless behaviour of ==.
>
> C# has primitives, but List<int> works, 5.ToString() works and if you do 
> happen to use Int32 instead of int, its == actually does the right thing 
> (compares the int, not the pointer).  You can still get at the Java-like 
> behaviour by casting both sides to object.
>
> In case anyone thinks that this is because .NET has reified generics:
>
> Scala doesn't really have primitives, but doesn't allocate a wrapper 
> object for Ints unless it really needs to, and in Scala List[Int] works, 
> 5.toString works and if you do happen to use java.lang.Integer instead of 
> Int, its == actually does the right thing (compares the Int, not the 
> pointer).  I'm not sure how you get at the Java-like behaviour though, 
> never needed it.
>
>

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/javaposse/-/MXVlhgz-SvMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to