renamed proc to builtin

master
Jordan Orelli 12 years ago
parent e86260e8dc
commit 18a8a9aea3

@ -4,7 +4,7 @@ import (
"errors" "errors"
) )
type proc func(...interface{}) (interface{}, error) type builtin func(...interface{}) (interface{}, error)
func addition(vals ...interface{}) (interface{}, error) { func addition(vals ...interface{}) (interface{}, error) {
a := accumulator{ a := accumulator{

@ -23,10 +23,10 @@ type symbol string
var universe = &environment{map[symbol]interface{}{ var universe = &environment{map[symbol]interface{}{
"#t": true, "#t": true,
"#f": false, "#f": false,
"+": proc(addition), "+": builtin(addition),
"-": proc(subtraction), "-": builtin(subtraction),
"*": proc(multiplication), "*": builtin(multiplication),
"/": proc(division), "/": builtin(division),
"define": special(define), "define": special(define),
"quote": special(quote), "quote": special(quote),
"if": special(_if), "if": special(_if),
@ -139,9 +139,9 @@ func eval(v interface{}, env *environment) (interface{}, error) {
} }
} }
p, ok := v.(proc) fn, ok := v.(builtin)
if !ok { if !ok {
return nil, fmt.Errorf("expected proc, found %v", reflect.TypeOf(v)) return nil, fmt.Errorf("expected builtin, found %v", reflect.TypeOf(v))
} }
if len(t) > 1 { if len(t) > 1 {
@ -153,14 +153,14 @@ func eval(v interface{}, env *environment) (interface{}, error) {
} }
args = append(args, v) args = append(args, v)
} }
inner, err := p(args...) inner, err := fn(args...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return eval(inner, env) return eval(inner, env)
} }
inner, err := p() inner, err := fn()
if err != nil { if err != nil {
return nil, err return nil, err
} }

Loading…
Cancel
Save