From: Tony Arcieri on
[Note: parts of this message were removed to make it a legal post.]

On Sun, Nov 8, 2009 at 1:15 PM, Walton Hoops <walton(a)vyper.hopto.org> wrote:

> Incorrect. In fact the very first message in this thread provided an
> example of redifining Fixnum in such a way that it was mutable.
>

No it didn't, that post created a new class called "FixNum"

And again, that's beside the point, which is to allow the expected "++"
semantics for immutable Numerics while also allowing in-place incrementation
for other classes which may store a mutable value, such as counters (whose
backing store may be a database, memcache, etc)

That would provide a truly Ruby-like ++ experience, aside from the fact you
can't redefine #++ for a Numeric, which probably isn't a good idea anyway.

--
Tony Arcieri
Medioh/Nagravision

From: Walton Hoops on
> -----Original Message-----
> From: bascule(a)gmail.com [mailto:bascule(a)gmail.com] On Behalf Of Tony
> No it didn't, that post created a new class called "FixNum"

I apologize, you are correct that post defined a new class, due to a
capitalization error, which was corrected a few posts down.

The point is, yes indeed, numerics can be mutable. I could if I were
so inclined write a String backed subclass of Numeric which represtend
integers as Roman Numerals and was mutable, (or Fixnum backed if we're
feeling boring).

> And again, that's beside the point, which is to allow the expected "++"
> semantics for immutable Numerics while also allowing in-place
> incrementation
> for other classes which may store a mutable value, such as counters
> (whosebacking store may be a database, memcache, etc)

But your missing the point that ++ is NOT expected. Not in Ruby. Ruby
simply doesn't work that way. You talked about "operator rebinding",
but you ignored the fact that ++ is nothing like those examples.

a+=<expression> expands to a=a+<expression>. It's a simple syntaxtic
sugar. a++ expands to... what? Nothing. There is no way you could
expand puts foo(a++,b) and get the desired behavior.

This discussion has gone on and on, and it's really quite pointless.
There is no good reason to include ++ in Ruby, and every reason not to.
No one can even agree on what they would expect a ++ operator to do when
used "The Ruby Way", with C programmers expecting it to work like C, and
the Rubyists expecting it to follow the Ruby way, with every operator
being a method call on that object (NOT variable).

So why introduce this operator into the language that would cause all
this confusion, when all it will do is save a few C programmers a SINGLE
line of code. 95% of the time it won't even do that, if they would
learn and do things the Ruby way, rather than trying to write C code in
Ruby.


From: Florian Aßmann on
Gaah, close this thread! ;)

Cheers
Florian

Am 08.11.2009 um 21:26 schrieb Tony Arcieri:

> On Sun, Nov 8, 2009 at 1:15 PM, Walton Hoops
> <walton(a)vyper.hopto.org> wrote:
>
>> Incorrect. In fact the very first message in this thread provided an
>> example of redifining Fixnum in such a way that it was mutable.
>>
>
> No it didn't, that post created a new class called "FixNum"
>
> And again, that's beside the point, which is to allow the expected "+
> +"
> semantics for immutable Numerics while also allowing in-place
> incrementation
> for other classes which may store a mutable value, such as counters
> (whose
> backing store may be a database, memcache, etc)
>
> That would provide a truly Ruby-like ++ experience, aside from the
> fact you
> can't redefine #++ for a Numeric, which probably isn't a good idea
> anyway.
>
> --
> Tony Arcieri
> Medioh/Nagravision


From: Marnen Laibow-Koser on
Florian Aßmann wrote:
> Gaah, close this thread! ;)

I don't think there's a mechanism for doing that, since this is an
unmoderated list. You don't have to follow it if you don't want to. :)

>
> Cheers
> Florian
>
> Am 08.11.2009 um 21:26 schrieb Tony Arcieri:

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen(a)marnen.org
--
Posted via http://www.ruby-forum.com/.

From: Tony Arcieri on
On Sun, Nov 8, 2009 at 2:30 PM, Florian Aßmann <florian.assmann(a)email.de>wrote:

> Gaah, close this thread! ;)
>

I suppose the whole discussion is moot as Ruby will likely never see a ++
operator.

I was just trying to make clear the limitation wasn't a technical one, and
further show how a ++ operator could be "Ruby-like" while still retaining
C/C++/Java-like semantics.

--
Tony Arcieri
Medioh/Nagravision