--
You received this message because you are subscribed to the Google Groups "The Mirah Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mirah+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
a = Foo.new(1)
b = a
c = Foo.new(1)
a === b # => true
a === c # => false
a == c # => true
a = Foo.new(1)
b = a
c = Foo.new(1)
a == b # => true
a == c # => false
a === c # => true
Actually, Ruby's behavior for === is pretty unusual. It isn't equality per se, instead it's the method that's invoked on arguments to when's in case expressions. I.e., Class's === does a kind_of? check, and regex's calls match.
case foo
when Foo then puts "a Foo"
when /[a-z]*/ then puts "lower case"
else puts "misc"
end
While I really want a good case syntax for Mirah, I think it's going to have to work differently from Ruby's, and I want that to be clear by changing the name of the callback for it.
In Java code I've read, == is sometimes, perhaps even frequently misused, particularly with strings. Maybe I've been reading too much java written by people use to languages where == compares values :-).
Also the first statement in most equals implementations tends to be checking for reference equality and the default implementation only checks for it. Because of that, I think the effect will be fairly small.
The cases that aren't covered are these:
- when you want to fail the check when the identity is different, but the value is the same.
- When you are checking references against self in an equals definition.
My thought is that the first case is relatively infrequent, and for the second, I'm adding a warning, and falling back to the old behavior at least for next release.
--