UNB/ CS/ David Bremner/ teaching/ cs4613/ docs/ stacker

stacker

⚠️ This is the documentation for the DrRacket based stacker. The author recommends you instead use the newer web-based stacker. ⚠️


Another implementation of smol. This implementation presents the execution with a stack-based model.

How to test whether an installation is successful?

First, make sure you are in the Racket language:

  1. Make sure you are in the DrRacket app.
  2. Go to the menu Language | Choose Language....

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.

image

Usage

Usually, you will use the Stacker like other Racket #langs.

#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)

Language Levels

  1. fun
  2. state adds mutable variables and mutable vectors
  3. hof adds first-class functions and let{,rec,*}

Grammar

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 ...