Executable semantics in C

Timon Gehr timon.gehr at gmx.ch
Wed Apr 27 14:20:46 PDT 2011


> Given that D is a new language, the first duty is to put less traps/undefined >
situations in the language, compared to C, even when this doesn't allow a
> perfectly efficient mapping on every CPU.
>
> Bye,
> bearophile

I think it is a good idea to just define the order to be left-to-right (every
operator is a sequence point). The compiler can always reorder evaluation of
subexpressions it can prove pure across sequence points. So you do not lose much.

It should always be better to make an arbitrary decision rather than leaving stuff
implementation-defined.

Something that goes in the same general direction:
Quiz: What does the following code compute?

import std.stdio;
import core.exception;
void main(){
	int a,b;
	int[int] aa;
	scanf("%d %d",&a,&b);
	try{aa[a]=aa[b];printf("Y\n");}catch(RangeError){printf("N\n");}
}



More information about the Digitalmars-d mailing list