From: Rick DeNatale on
On Wed, Nov 4, 2009 at 11:55 AM, Seebs <usenet-nospam(a)seebs.net> wrote:
> On 2009-11-04, Yukihiro Matsumoto <matz(a)ruby-lang.org> wrote:
>> In message "Re: Ruby doesn't implement x++ for Fixnum's because ???"
>>     on Wed, 4 Nov 2009 23:31:46 +0900, Marnen Laibow-Koser <marnen(a)marnen.org> writes:
>
>>|I believe you are quite wrong.  If a destructive function like gsub! can
>>|be implemented as a method, then I see no reason that +=, |=, or postfix
>>|++ couldn't be.
>
>> Only if you accept the language that can change the value of 1 to 2.
>> I don't.
>
> Hmph.  Fortran can change constants, why's Ruby so much less powerful?

But Fortran fixed that bug in its first revision!

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

From: Gavin Sinclair on
>
> What's wrong with Array#push?  Why do we need Array#<<?  How is that any
> different?

Apart from David's response, you're proposing that a currently-invalid
method name be allowed. For such a change, there needs to be a good
reason.

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

On Thu, Nov 5, 2009 at 5:28 PM, David A. Black <dblack(a)rubypal.com> wrote:

> The thing is, a method called ++ that did in-place incremention would not
> be meaningful for
> numbers (if I understand correctly that you mean it would be similar
> to succ!), and having it for other objects would probably just lead to
> more confusion. That's my hunch, at least.


There's no point at all if it doesn't work on numbers.

It would require special case behavior. Application to literal numbers
would be strange. But there's certainly no reason it can't be done, and you
have one Ruby implementer on this thread attesting that it can.

--
Tony Arcieri
Medioh/Nagravision

From: David A. Black on
Hi --

On Sat, 7 Nov 2009, Tony Arcieri wrote:

> On Thu, Nov 5, 2009 at 5:28 PM, David A. Black <dblack(a)rubypal.com> wrote:
>
>> The thing is, a method called ++ that did in-place incremention would not
>> be meaningful for
>> numbers (if I understand correctly that you mean it would be similar
>> to succ!), and having it for other objects would probably just lead to
>> more confusion. That's my hunch, at least.
>
>
> There's no point at all if it doesn't work on numbers.

It depends how you define "work" :-) I'll stick with my formulation,
though: in-place incrementation of a numeric is not meaningful. So if
++ is understood to be in-place incrementation (like succ!), which is
how I interpreted your earlier post, then it wouldn't be meaningful
for numbers.

> It would require special case behavior. Application to literal numbers
> would be strange. But there's certainly no reason it can't be done, and you
> have one Ruby implementer on this thread attesting that it can.

It seems like a lot of special-casing and strangeness, though. I'm a
little bit hampered in discussing it, I guess, because I don't see
what benefit it would confer in exchange for the anomaly. So I'm
probably going in circles.


David

--
The Ruby training with D. Black, G. Brown, J.McAnally
Compleat Jan 22-23, 2010, Tampa, FL
Rubyist http://www.thecompleatrubyist.com

David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)

From: Seebs on
On 2009-11-06, David A. Black <dblack(a)rubypal.com> wrote:
> It seems like a lot of special-casing and strangeness, though. I'm a
> little bit hampered in discussing it, I guess, because I don't see
> what benefit it would confer in exchange for the anomaly. So I'm
> probably going in circles.

I have found a lot of idioms which are amenable to use with ++, especially
postincrement, but they are often not nearly so useful outside of the C-like
languages.

Consider the canonical inner loop for copying an array in C:
s[i++] = t[j++];

There's really no idiomatic equivalent -- nor a need for one, usually.

-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!