diff options
Diffstat (limited to 'alv/builtins.moon')
| -rw-r--r-- | alv/builtins.moon | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/alv/builtins.moon b/alv/builtins.moon index 84978f1..6e36c7e 100644 --- a/alv/builtins.moon +++ b/alv/builtins.moon @@ -12,7 +12,7 @@ import import Constant from require 'alv.result' import Error from require 'alv.error' import RTNode from require 'alv.rtnode' -import Cell from require 'alv.cell' +import Cell, ArrayCell from require 'alv.cell' import Dummy from require 'alv.dummy' import Scope from require 'alv.scope' import Tag from require 'alv.tag' @@ -194,7 +194,7 @@ fn = Constant.meta meta: name: 'fn' summary: "Declare a function." - examples: { '(fn (p1 [p2…]) body-expr)' } + examples: { '(fn [p1 p2…] body-expr)' } description: " The symbols `p1`, `p2`, ... will resolve to the arguments passed when the function is invoked." @@ -205,7 +205,7 @@ function is invoked." assert #tail == 2, "'fn' takes exactly two arguments" { params, body } = tail - assert params.__class == Cell, "'fn's first argument has to be an expression" + assert params.__class == ArrayCell, "'fn's first argument has to be a [parmeter list]" param_symbols = for param in *params.children assert param.type == T.sym, "function parameter declaration has to be a symbol" param @@ -220,7 +220,7 @@ defn = Constant.meta meta: name: 'defn' summary: "Define a function." - examples: { '(defn name-sym (p1 [p2…]) body-expr)' } + examples: { '(defn name-sym [p1 p2…] body-expr)' } description: " Declare a function and define it as `name-sym` in the current scope. The symbols `p1`, `p2`, ... will resolve to the arguments passed when the @@ -233,7 +233,7 @@ function is invoked." { name, params, body } = tail name = name\unwrap T.sym - assert params.__class == Cell, "'defn's second argument has to be an expression" + assert params.__class == ArrayCell, "'defn's second argument has to be a [parameter list]" param_symbols = for param in *params.children assert param.type == T.sym, "function parameter declaration has to be a symbol" param @@ -636,7 +636,7 @@ loop = Constant.meta meta: name: 'loop' summary: "Loop on arbitrary data via recursion." - examples: { '(loop (k1 v1 [k2 v2…]) body)' } + examples: { '(loop [k1 v1 [k2 v2…]] body)' } description: " Defines a recursive loop function `*recur*` with parameters `k1`, `k2`, … and function body `body`, then invokes it immediately with arguments `v1`, `v2`, … @@ -644,7 +644,7 @@ function body `body`, then invokes it immediately with arguments `v1`, `v2`, … Inside the `body`, `(recur)` is used to recursively restart loop evaluation with a different set of arguments, e.g. to sum the first `5` integers: - (loop (n 5) + (loop [n 5] (if (= n 0) 0 (+ n (recur (n - 1)))))" @@ -655,7 +655,7 @@ with a different set of arguments, e.g. to sum the first `5` integers: assert #tail == 2, "'loop' takes exactly two arguments" { binds, body } = tail - assert binds.__class == Cell, "loops bindings have to be an cell" + assert binds.__class == ArrayCell, "loops bindings have to be a [parameter list]" assert #binds.children % 2 == 0, "key without binding in loop binding" names = {} |
