-
Notifications
You must be signed in to change notification settings - Fork 1
Stack Notation
Dev Note: I am not too happy with the current notation, so this may be subject to change in the future. I am also thinking about backing the notation with a proper type-checker implementation.
In the commands reference, you may notice that each command has
a Stack: entry. These entries informally describe how the command affects the
stack. Take for example the following signature for swap:
a b -> b a
Here, b is the top of the stack and a is second from top of the stack. ->
separates the "before" and "after" parts of the signature.
Another signature, this time for roll:
(a @ n) b* (n >NUM) -> b* a
Looks kinda gnarly right? Let's break it down.
-
n >NUMmeans thatnis implicitly converted toNUMat the argument level. -
a @ nmeans thataisnpositions from the top of the stack (0-indexed). Son = 0is the top of the stack,n = 1is second from the top of the stack,n = 2is third from the top of the stack, etc. -
b*means that 0 or more items may exist at that location in the stack.
Other notation to know:
-
a'means thatavectorizes -
SEQ[NUM*]means aSEQcontaining 0 or moreNUMs -
MAP[(STR => NUM)*]means aMAPcontainingSTRkeys andNUMvalues -
a.xmeans a valuexthat is an item ina -
a | bmeans "aorb." -
f: x -> _means a valuefthat evaluates using the stack signaturex -> _.
Made with ❤️ by Ben Pang (@molarmanful).