« lists coming from methods | Main | no means yes and yes means no »
November 06, 2004
quoted lists
CX, being implemented in java, uses objects in the implementation for lists and quotes. There are times when a list is really a quote until finally being contextualized into a list.
For example:
set["x" {+[2 c]}]
set["c" 3]
x => 5
In this code, x is set to be a quote: +[2 c]. the list in this quote is special because the letter 'c' wasn't evaluated on the spot. The whole list had to be implemented as a special kind of quote. when the quote is refered to , it will be evaluated into the list as though it was [2 c] the whole time.
The parser knows when to do this by having a quote-level counter. For every '{' encountered, the quote level goes up, and the quote level goes down for every '}' character found. The quote level starts at 0, so if the parser encounters a beginning of a list, it checks the quote level for being above zero. If it is above zero, the list is made as a quote. Else, the list is just a list.
So, if the list in { [ here ] } is parsed to be a quote, then when things are sent to the evaluater, how does the evaluater know if it was { { this } } or the previous? The object used for holding quotes has an instance boolean called 'returnList', which tells this information. Here is the source file for the quote, which is called Stack.java because of how it operates.
Posted by Rex at November 6, 2004 04:22 PM