== and === #42

Open
hakunin opened this Issue Jan 17, 2011 · 3 comments

Projects

None yet

3 participants

@hakunin
hakunin commented Jan 17, 2011

Looks like another step towards more Ruby-like and expressive syntax would be:

`==`  -> `a.equals(b)`
String.new("a") == String.new("a")
Integer.new(1) == Integer.new(1)

This is helpful when comparing values, which we are in most common cases

`===` -> `a == b`
String.new("a") !== String.new("a")
Integer.new(1) !==Integer.new(1)

Thiw would map Java's standard behaviour it to Mirah's, without changing how it works.

@baroquebobcat
Member

We could do it Ruby style--where == usually delegates to equals, eql? and equal? are used for object identity and === does the sensible thing for a case statement.

We don't have case statements currently, but we should try to figure out whether we want them to act like Ruby's case or like Java's switch.

@consiliens
Contributor

"Comment 3 by ndh.000...@gmail.com, May 22, 2011
Ruby uses '===' as the case operator, ie how comparisons happen in a when of a case statement. In Ruby object identity is handled using 'eql?'

do we want to follow Ruby or introduce a different thing?
What languages use '===' for object identity?

Comment 4 by michal.h...@gmail.com, May 22, 2011

do we want to follow Ruby or introduce a different thing?

I'd go with == and === for comparisons.

What languages use '===' for object identity?

JavaScript and PHP"
http://code.google.com/p/mirah/issues/detail?id=20

@baroquebobcat
Member

The == to equals bit is covered by #127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment