Do we dare add ++ and -- ?
Here's a question to think about for 3.0. (I'm sure I asked this before, but let's revisit it again).
Do we dare add the C-style ++ and -- functions as a standard part of REBOL 3.0?
| Advantage | a handy shortcut used by most C programmers.
|
| Disadvantage | modifies a word without using the SET-WORD notation
(of course, you can already do that in REBOL) and adds noise to expressions (looks like an infix operator, but is not -- see examples at end).
|
Examples:
count: 0
++ count ; add one
-- count ; sub one
Notes:
- increments or decrements value by one
- returns the new value
- could also be allowed for series values to change index position
- only prefix. No postfix form (e.g. n ++).
- function precedence, same as negate. (Makes it less useful in non paren expressions.)
Example of last point, this is not valid:
if ++ count > 10 [...]
Just like you cannot write:
if negate count > 10 [...]
You either need to use prefix, reverse the comparison, or paren it:
if greater? ++ count 10 [...]
if 10 <= ++ count [...]
if (++ count) > 10 [...]
So, there you are. Useful or not useful as a standard part of REBOL? Tell us.
41 Comments
|