Project

General

Profile

Actions

Feature #1432

closed

decrement and increment

Added by OlegPuchinin (Oleg Puchinin) almost 15 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:23357]

Description

=begin
What about (C) ++/-- ?
=end

Actions #1

Updated by matz (Yukihiro Matsumoto) almost 15 years ago

  • Status changed from Open to Rejected

=begin
You can't define object-oriented semantics for increment/decrement operations. They are assignments in theory.

=end

Actions #2

Updated by rogerdpack (Roger Pack) almost 15 years ago

=begin
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
=end

Actions #3

Updated by brent (Brent Roman) almost 15 years ago

=begin

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.

=end

Actions #4

Updated by rogerdpack (Roger Pack) almost 15 years ago

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

Actions #5

Updated by matz (Yukihiro Matsumoto) almost 15 years ago

=begin
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" 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.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0