Another implementation of smol. This implementation presents the execution with a stack-based model.
Please follow these instructions to install or update
- Make sure you are in the
DrRacket
app. - Go to the menu
File
|Package Manager...
. A window will pop up. - Make sure you are in the
Do What I Mean
tab of the pop-up window. - Set the
Package Source
field toStacker
(orhttps://github.com/LuKuangChen/stacker.git
) - Click the
Show Details
button. - Set the
Dependencies Mode
field toAuto
. - Click the
Install
button. (If you have already installed, you will see "Update" instead of "Install".) Most buttons will grey out immediately (except theAbort Install
). - After the color of those buttons comes back, you can close the pop-up window. This usually takes less than 1 min.
Alternatively, you if the raco
tool is availabe, you can install by running raco pkg install Stacker
.
To uninstall
- Make sure you are in the
DrRacket
app. - Go to the menu
File
|Package Manager...
. A window will pop up. - Make sure you are in the
Currently Installed
tab of the pop-up window. - Set the
Filter
field tostacker
. - Select the first result.
- Click the
Remove
button. A confirmation window will pop up. - Click the
Remove
button in the confirmation window. Most buttons will grey out immediately (except theAbort Install
). - After the color of those buttons comes back, you can close the pop-up window. This usually takes less than 1 min.
First, make sure you are in the Racket language:
- Make sure you are in the
DrRacket
app. - Go to the menu
Language
|Choose Language...
. A window will pop up. - Select
The Racket Language
. - Click the
OK
button.
Run the following program in DrRacket
#lang stacker/smol/hof
(defvar x 2)
(defvar y 3)
(+ x y)
You should see a screenshot like this.
Usually, you will use the Stacker like other Racket #lang
s.
#lang stacker/smol/hof
(deffun (fact n)
(if (zero? n)
1
(* (fact (- n 1)) n)))
(fact 3)
If you only want to see the (final) result, you can ask the stacker not to show the stack+heap configurations (note the second line). This way you don't need to click through the configurations and hence can see the result sooner.
#lang stacker/smol/hof
#:no-trace
(deffun (fact n)
(if (zero? n)
1
(* (fact (- n 1)) n)))
(fact 3)
fun
state
adds mutable variables and mutable vectorshof
adds first-class functions andlet{,rec,*}
Here is a glossary of smol
grammar, where d
stands for definitions, e
stands for expressions, c
stands for constants, and x
and f
are identifiers (variables).
d ::= (defvar x e)
| (deffun (f x ...) body)
e ::= c
| x
| (lambda (x ...) body)
| (λ (x ...) body)
| (let ([x e] ...) body)
| (letrec ([x e] ...) body)
| (let* ([x e] ...) body)
| (begin e ... e)
| (set! x e)
| (if e e e)
| (cond [e e] ... [else e])
| (cond [e e] ...)
| (e e ...)
body ::= d ... e ... e
program ::= d ... e ...