www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Executable semantics in C

reply Robert Clipsham <robert octarineparrot.com> writes:
Just read another excellent article by John Regehr, this time about 
executable semantics:

http://blog.regehr.org/archives/523

They seem to be creating a pretty complete system for identifying bugs 
and reducing test cases. A similar tool could be useful for D, it's a 
huge task though.

Of course, as mentioned in reply to the last thread, D has plenty of its 
own bugs to worry about before getting onto things like this, it's an 
interesting read regardless though.

-- 
Robert
http://octarineparrot.com/
Apr 27 2011
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Robert Clipsham:

 They seem to be creating a pretty complete system for identifying bugs 
 and reducing test cases. A similar tool could be useful for D, it's a 
 huge task though.
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
Apr 27 2011
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
 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");} }
Apr 27 2011
parent reply Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
On 27/04/2011 22:20, Timon Gehr wrote:
 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");}
 }
What was your point here? Is there even any way an associative array throws a RangeError? -- Bruno Medeiros - Software Engineer
May 03 2011
parent reply "Robert Jacques" <sandford jhu.edu> writes:
On Tue, 03 May 2011 08:20:42 -0400, Bruno Medeiros  
<brunodomedeiros+spam com.gmail> wrote:

 On 27/04/2011 22:20, Timon Gehr wrote:
 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");}
 }
What was your point here? Is there even any way an associative array throws a RangeError?
An AA throws a range error if the key is not in the AA during an index operation. Since aa is initialized, aa[b] would be expected to throw a range error.
May 04 2011
next sibling parent Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
On 04/05/2011 14:45, Robert Jacques wrote:
 On Tue, 03 May 2011 08:20:42 -0400, Bruno Medeiros
 <brunodomedeiros+spam com.gmail> wrote:

 On 27/04/2011 22:20, Timon Gehr wrote:
 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");}
 }
What was your point here? Is there even any way an associative array throws a RangeError?
An AA throws a range error if the key is not in the AA during an index operation. Since aa is initialized, aa[b] would be expected to throw a range error.
Duh me, of course. For a moment I thought that wasn't the case, I ran a snippet to test that and no RangeError was thrown. But it turns out what I had ran was the old version of the code, not the new one that I modified and thought was running. -- Bruno Medeiros - Software Engineer
May 04 2011
prev sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
Robert Jacques wrote:
On Tue, 03 May 2011 08:20:42 -0400, Bruno Medeiros
<brunodomedeiros+spam com.gmail> wrote:

 On 27/04/2011 22:20, Timon Gehr wrote:
 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");}
 }
What was your point here? Is there even any way an associative array throws a RangeError?
An AA throws a range error if the key is not in the AA during an index operation. Since aa is initialized, aa[b] would be expected to throw a range error.
I guess you meant uninitialized. Fact is, it won't always throw. You might want to test the program with a few values for a and b. Timon
May 06 2011
prev sibling parent bearophile <bearophileHUGS lycos.com> writes:
 even when this doesn't allow a perfectly efficient mapping on every CPU.
Look at Ada to see how this is done. Ada runs on small CPUs&RAM too. Bye, bearophile
Apr 27 2011