renamed proc to builtin

master
Jordan Orelli 12 years ago
parent e86260e8dc
commit 18a8a9aea3

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

@ -23,10 +23,10 @@ type symbol string
var universe = &environment{map[symbol]interface{}{
"#t": true,
"#f": false,
"+": proc(addition),
"-": proc(subtraction),
"*": proc(multiplication),
"/": proc(division),
"+": builtin(addition),
"-": builtin(subtraction),
"*": builtin(multiplication),
"/": builtin(division),
"define": special(define),
"quote": special(quote),
"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 {
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 {
@ -153,14 +153,14 @@ func eval(v interface{}, env *environment) (interface{}, error) {
}
args = append(args, v)
}
inner, err := p(args...)
inner, err := fn(args...)
if err != nil {
return nil, err
}
return eval(inner, env)
}
inner, err := p()
inner, err := fn()
if err != nil {
return nil, err
}

Loading…
Cancel
Save