Add 'quote' special form

This commit is contained in:
Sameer Rahmani 2020-11-26 12:03:46 +00:00
parent 688d169286
commit 211e977430
1 changed files with 20 additions and 0 deletions

View File

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