From 211e977430d1d1d4d6583acf89a4f6d03a5215d5 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Thu, 26 Nov 2020 12:03:46 +0000 Subject: [PATCH] Add 'quote' special form --- bootstrap/pkg/core/eval.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bootstrap/pkg/core/eval.go b/bootstrap/pkg/core/eval.go index ca20e5b..f4115e7 100644 --- a/bootstrap/pkg/core/eval.go +++ b/bootstrap/pkg/core/eval.go @@ -153,10 +153,30 @@ tco: } switch sform { + + // `quote` evaluation rules: + // * Only takes one argument + // * Returns the argument without evaluating it + case "quote": + // Including the `quote` itself + if list.Count() != 2 { + return nil, MakeErrorFor(rt, list, "'quote' quote only accepts one argument.") + } + return list.Rest().First(), nil + + // `def` evaluation rules + // * The first argument has to be a symbol. + // * The second argument has to be evaluated and be used as + // the value. + // * Defines a global binding in the current namespace using + // the symbol name binded to the value case "def": ret, err = Def(rt, scope, list.Rest().(*List)) break tco // return + // `fn` evaluation rules: + // * It needs at least a collection of arguments + // * Defines an anonymous function. case "fn": ret, err = Fn(rt, scope, list.Rest().(*List)) break tco // return