Changing the behavior of the comma operator

Steven Schveighoffer schveiguy at yahoo.com
Tue Mar 25 14:02:21 PDT 2014


On Tue, 25 Mar 2014 15:25:42 -0400, ixid <nuaccount at gmail.com> wrote:

>> I think this should not be done. Note that even though code which is D  
>> could reintroduce commas safely, C code will still exist at that time,  
>> and likely need porting to D. The principle that C code should either  
>> do the same thing, or not compile, would be violated.
>
> What would be an example of C code that would compile in a D
> where the comma operator was used for tuples? Also why is cut and
> pasting C code to D so important? If it's non-trivial surely
> people will just use extern C. If it's trivial they can make the
> minor improvements necessary.

It's not so much that it's important that it works, it's important that if  
it does work, it does the same thing.

Why? Because it's a stated goal of D. We want to be able to easily port C  
code to D, without having silent errors.

I don't have examples, I don't use the comma operator for anything except  
for loops. If there are no cases of legitimate C code that would compile  
incorrectly in D, then my objection is not valid. In either case, I'm fine  
with the proposal up to step 4. Changing the result of a comma expression  
later would be debated at the time we wanted to introduce it again, and  
that is going to be a long time in the future, there is no rush.

-Steve


More information about the Digitalmars-d mailing list