Hacker News new | ask | show | jobs
by strong_code 3783 days ago
I understand the perceived benefit of compositional eloquence that this may add (pretty much borrowing from Python) but as others have pointed out, this is incongruent to the design of Ruby as a language and how it treats the relation between objects and their methods. Additionally, you lose any compositional elegance you may have gained when you decided not to use:

  x not in y
and instead propose:

  !(x in y)
Seems like a zero-sum addition to the language to me.
1 comments

I find `not in` highly dubious - it makes the expression grammar awkward and harder to parse. Is `not in` a two-token operator? Or is `not` an adverb in this context? What else resembles this?

To cite an alternatice, in Tcl, `in` is an operator and its negation is `ni`. A cute pun and echo of Monty Python that I'm disappointed Python didn't follow :).

You should be happy, as Python 3 would have renamed it to "Ekke Ekke Ekke Ekke Ptang Zoo Boing!"

As to the "what else resembles this"? I would turn it around and ask what else could resemble this. I'm not sure the conclusion would be that "not in" is a good thing, but not sure of the reverse, either:

  if x not = 3
looks weird, but I think I could grow to like it.
Well, shell has the '-ne' operator, which is 'not equals' in a terser style.

Really '!=' is just an attempt at rendering '≠' using only ASCII characters. They're a bit like digraphs and trigraphs in C/C++, except everyone is used to them.

I wonder if Unicode is ubiquitous enough now that you could write a language where the real maths operators were used instead. What would that look like?

Haskell allows unicode in operators and there appear to be packages that implement aliases for the default ASCII versions.

https://wiki.haskell.org/Unicode-symbols

Scala allows using unicode arrows (→) in place of their ASCII version (->), but not things like '≠'.

I'm currently using the Monoid font (https://larsenwork.com/monoid/), which uses ligatures to achieve the visual effect of things like the not equals symbol, while the underlying code remains the same. It's a pretty nice work-around for current languages.

Another alternative is the way D does it. Its the same idea as `not in` but instead of adding a 2 keyword operator and non-standard usage of negation (`not` instead of `!`) it is simply: `!in`