Things that may be removed

Yigal Chripun yigal100 at gmail.com
Wed Dec 24 14:24:54 PST 2008


Don wrote:
> bearophile wrote:
>> Nick Sabalausky:
>>> Disagree. Octal can often useful on low-level embedded stuff.
>>
>> I think the point was to improve the syntax of octal numbers, not to
>> remove them. So 0125 becomes a syntax error (as usual to keep
>> compatibility with C, otherwise it's better to make it just mean 125),
>> and invent a less error-prone syntax for octal numbers. For example
>> 0oxxxx.
>
> Exactly. I just think it's ridiculous that octal has a privileged syntax:
> int a = 06;
> int b = 09;
> either both lines should compile, or neither.
> I like the 0c635 syntax.
>
>>>> * the comma operator (allow in selected places, eg for(; ;++a, ++b)).
>>> What is the problem with these?
>>
>> Generally the comma operator is useful only in particular situations,
>> and in other situations it may lead to errors.
>>
>> This is an acceptable use (but this too may lead to some errors):
>> for( i = 0, j = MAX; i <= j; ++i, --j )
>>
>> This shows some of the stupid uses of the comma operator:
>> http://stackoverflow.com/questions/54142/c-comma-operator
>>
>> A way to use the comma operator is to allow multiple simultaneous
>> assignments:
>> x, y = y, x
>> a, b, c = c, b, a
>> Etc.
>> (The compiler can minimize the operations and intermediate memory
>> required to do that).
>
> That would be useful, but it's not the comma operator.
>>
>> Bye,
>> bearophile

why not replace the current comma operator with tuple support?
the comma op needs to be higher than assingment in precedence and 
instead of evaluating the expressions left to right and returning the 
value of the _last_ expression as the return value of the op, return 
_all_ expressions' return values as a value tuple. the current behavior 
that is really used only in for loops can be implemented with tuples as 
well.

insted of:
for (int i = 0, long j = 0; ...; ...) {...}

we'll use something like:
for (Tuple!(int, long) (a, b) = (0, 0); ...; ...) {...}

-- Yigal







More information about the Digitalmars-d mailing list