catb0t / cat-language

Automatically exported from code.google.com/p/cat-language
Other
0 stars 0 forks source link

Definition of whilene not working #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Implement the level 0 primitives
2. Implement a way of defining the level 1 primitives using level 0 primitives
3. Attempt to define whilene and the other level 1 primitives (about 17)
that depend on it, and run all of the unit tests.

What is the expected output? What do you see instead?

The expected output in all cases should be the stack containing only true
-- specifically each of the tests should pass.  Instead, you see uncons (or
some other list opeartion) complain because it ends up being called on
something that isn't a list.

Please provide any additional information below.

The reason for this problem is that the definition of whilene in the
primitives documentation online is stated as:
   Implementation   [empty not] while pop
Unfortunately, the first time this executes the (empty not), the list will
be taken off the stack (see the definition of empty).  To fix this, change
the definition to
   Implementation   [dup empty not] while pop
This will make a copy of the list on the top of the stack, then replace the
top copy with whether it is empty.  This will make everything work.  I have
done this on my scheme implementation of all of the primitives from level 0
and 1 (except for the combinators) and this is the only way to get all of
the unit tests to pass.

Original issue reported on code.google.com by bjchamb...@gmail.com on 25 Sep 2007 at 6:44

GoogleCodeExporter commented 8 years ago
Fixed. Empty no longer pops stuff off the stack. 

Original comment by cdiggins on 6 Apr 2008 at 4:07