Except 1++ wouldn't work, any more than 1 += 1 would work.
Again, the suggestion was that it work the same way += does -- and += doesn't
rely on a .succ! method of any kind. It would be purely syntactic sugar, the
way +=.
In other words, it would still parse to:
foo = foo + 1
Or, maybe slightly better, it would parse to:
foo = foo.succ
it would just be shorter to write than
foo += 1
The immutability of integers is a good thing for people to know, yes.
It's also completely irrelevant to this discussion.
And for the record, I'm playing devil's advocate -- the real issue seems to be
that ++ would add to the parsing complexity of it. I'm guessing most of us
rarely do +=1, so most of us wouldn't really use it, so it's not worth that
complexity.
But it's by no means impossible, or a fundamental change to the language.
All it does is make the parser more complex.
···
On Saturday 30 August 2008 13:11:38 Erik Hollensbe wrote:
David Masover wrote:
> Why not add a ++ that works the same way += does?
1++ would have to operate (essentially) like 1.succ!
... Then again, why pollute our namespace with an operator that would see
so
little use? I can't remember the last time I had to use "+=1" in Ruby.
I wish we had it. But that's just me.
Ruby doesn't use ++ because that would .succ!
No it would not, and if you have good memories you know who was the
fool who proposed succ! once, LOL.
The worst is that this confusion is totally my fault because I was
talking about Integer's immutability completely out of context.
Sorry.
R.
···
On Fri, Aug 29, 2008 at 3:25 PM, Phlip <phlip2005@gmail.com> wrote: