Feature #1432 [ruby-core:23357]

decrement and increment

Added by Oleg Puchinin 319 days ago. Updated 319 days ago.

Status :Rejected Start :05/04/2009
Priority :Low Due date :
Assigned to :- % Done :

0%

Category :-
Target version :-

Description

What about (C) ++/-- ?

History

05/04/2009 07:56 PM - Yukihiro Matsumoto

  • Status changed from Open to Rejected
You can't define object-oriented semantics for increment/decrement operations.  They are assignments in theory.

05/06/2009 11:02 AM - Roger Pack

at times I do miss the elegance of being able to do ++
though it does hide the fact that it's internally assignment.  Primitives aren't quite as objecty as "normal" objects, so might be an appropriate fit.  Just thinking out loud. 
-=r

05/06/2009 11:31 AM - Brent Roman

Why is

  a+=1

less elegant than 

  ++a

However, I admit that using

  (x=a; a+=1; x)

to replace

  a++

is pretty evil looking.  (The postfix variants *are* a pain to emulate
correctly)

Are there other commonly used languages besides 'C' that support the ++ and
-- operators?
I always thought they were added to 'C' primarily to support efficient
pointer arithmetic --
something quite foreign to Ruby.

- brent



Nobuyoshi Nakada-3 wrote:
> 
> Issue #1432 has been updated by Roger Pack.
> 
> 
> at times I do miss the elegance of being able to do ++
> though it does hide the fact that it's internally assignment.  Primitives
> aren't quite as objecty as "normal" objects, so might be an appropriate
> fit.  Just thinking out loud. 
> -=r
> ----------------------------------------
> http://redmine.ruby-lang.org/issues/show/1432
> 
> ----------------------------------------
> http://redmine.ruby-lang.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-ruby-core%3A23357---Feature--1432--decrement-and-increment-tp23366229p23399031.html
Sent from the ruby-core mailing list archive at Nabble.com.

05/09/2009 12:33 PM - Roger Pack

yeah ++ is the one I miss.
-=r

05/09/2009 08:42 PM - Yukihiro Matsumoto

Hi,

In message "Re: [ruby-core:23405] Re: [Feature #1432] decrement and increment"
    on Sat, 9 May 2009 15:38:53 +0900, "C.E. Thornton" <admin@hawthorne-press.com> writes:

|The question comes down to this:
|
|    Are we going to allow "Synatic Suger" of this
|    sort into Ruby?  We already do in sense - By allowing
|    more than one way to do things in most situations.

The answer is

  we have to mind to add sugars easily

just because syntax sugar is modifying the syntax, and you have to be
slow to modify the syntax.

If we decide to add this particular sugar after serious consideration,
the following question arise:

 what is the result of "syntax sugar" conversion.  simple += 1 is
 suffice, or no?

							matz.

Also available in: Atom PDF