Today, I added a keyword called freeze to Marvin3.
Basically, when called inside a routine, it pops the top element from the stack and replaces routine's code with a word that pushes that value onto the stack.
This way we can create a write-once routine, which is similar to C#'s readonly
modifier (value is allowed to be set once).
Consider the following example:
:YOUR-NUMBER input int freeze ;
"Enter a number:" prints YOUR-NUMBER
YOUR-NUMBER " is a nice number!" cat println
Notice that, although YOUR-NUMBER
is a routine, when called, it just pushes the same value determined when it is first called.
Here is a more complex one. …continue.