Feature #1432

decrement and increment

Added by Oleg Puchinin almost 3 years ago. Updated 9 months ago.

[ruby-core:23357]
Status:Rejected Start date:05/04/2009
Priority:Low Due date:
Assignee:- % Done:

0%

Category:-
Target version:-

Description

What about (C) ++/-- ?

History

Updated by Yukihiro Matsumoto almost 3 years ago

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

Updated by Roger Pack almost 3 years ago

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

Updated by Brent Roman almost 3 years ago

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.

Updated by Roger Pack over 2 years ago

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

Updated by Yukihiro Matsumoto over 2 years ago

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