Penguin

Differences between current version and revision by previous author of Aym.

Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History

Newer page: version 6 Last edited on Friday, November 24, 2006 5:58:21 pm by AlastairPorter
Older page: version 5 Last edited on Wednesday, March 16, 2005 11:44:52 am by CraigBox Revert
@@ -3,32 +3,40 @@
 !A Really Bad Example 
  
 Aym Specification: 
  
+<pre>  
  function sum(x) of type integer returning integer 
  let sum(0) = 0 
  let sum(x) = x + sum(x-1) 
+</pre>  
  
 C++ Implementation: 
  
+<pre>  
  int sum( int x ) 
 
  int count = 0; 
  for(int i = 0; i<x; i++) { 
  count += i; 
 
  return count; 
 
+</pre>  
  
 Notice that these two functions return completely different results! The idea is that the unit-testing portion of the project would catch this and inform you of the input, expected output and actual output. 
  
-[Aym] also supports the idea of "watches", whereby __internal__ values of the specification and implementation can be made to match, not just returned results. This is facilitated by the use of a function ''! AymWatch'', of type string * 'a -> 'a. Using the above example again, one might insert a watch into the last line of the specification such as: 
+[Aym] also supports the idea of "watches", whereby __internal__ values of the specification and implementation can be made to match, not just returned results. This is facilitated by the use of a function ''~ AymWatch'', of type string * 'a -> 'a. Using the above example again, one might insert a watch into the last line of the specification such as: 
  
- let sum(x) = ! AymWatch("sumwatch", x) + sum(x-1) 
+<pre>  
+ let sum(x) = ~ AymWatch("sumwatch", x) + sum(x-1)  
+</pre>  
  
 And then the implementation would have a line added to it such as: 
  
- ! AymWatch("sumwatch", i); 
+<pre>  
+ ~ AymWatch("sumwatch", i);  
+</pre>  
  
 The unit-testing framework will ensure that the values match at each update. 
  
 Aym is GPLish. If you want a copy (''why?''), talk to GianPerrone or AlastairPorter.