digitalmars.D - Executable semantics in C
- Robert Clipsham (12/12) Apr 27 2011 Just read another excellent article by John Regehr, this time about
- bearophile (4/7) Apr 27 2011 Given that D is a new language, the first duty is to put less traps/unde...
- Timon Gehr (16/20) Apr 27 2011 I think it is a good idea to just define the order to be left-to-right (...
- Bruno Medeiros (5/14) May 03 2011 What was your point here? Is there even any way an associative array
- Robert Jacques (5/18) May 04 2011 An AA throws a range error if the key is not in the AA during an index
- Bruno Medeiros (7/26) May 04 2011 Duh me, of course. For a moment I thought that wasn't the case, I ran a
- Timon Gehr (5/24) May 06 2011 I guess you meant uninitialized.
- bearophile (3/4) Apr 27 2011 Look at Ada to see how this is done. Ada runs on small CPUs&RAM too.
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
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
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 aperfectly efficient mapping on every CPU. Bye, bearophileI 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
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
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: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.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?
May 04 2011
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: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 EngineerOn 27/04/2011 22:20, Timon Gehr wrote: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.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?
May 04 2011
Robert Jacques wrote:On Tue, 03 May 2011 08:20:42 -0400, Bruno Medeiros <brunodomedeiros+spam com.gmail> wrote: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. TimonOn 27/04/2011 22:20, Timon Gehr wrote: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.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?
May 06 2011
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