4 ms·
> @1, @2 are names, and they're no better than fst, snd. They are better than fst and snd in a new iteration of Ruby, because giving a special meaning to exist
by dragonwriter 8y ago
> @1, @2 are names, and they're no better than fst, snd.
They are better than fst and snd in a new iteration of Ruby, because giving a special meaning to existing legal identifiers in certain contexts risks breaking existing code; @1 and @2 (despite the similarity to instance variable notation) are not legal identifiers in existing Ruby so their special role has no effect on existing code.
- Retra 8y ago>giving a special meaning to existing legal identifiers in certain contexts risks breaking existing code That's just what scoped variables are. I've never seen it be a hazard other than shadowing names, and you'll have the same problem with @1, @2, etc. A closure returning a closure for instance. Unless you're just completely misunderstanding me, thinking I'd be a proponent of fst, snd as direct substitutions for @1, @2? That would be absurd. I'm comparing |fst,snd| fst+snd to @1+@2. Code isn't going to break with either.