You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
361 B
Go

package main
import (
"fmt"
)
type UnknownSymbolError struct{ symbol }
func (u UnknownSymbolError) Error() string {
return fmt.Sprintf(`unknown symbol "%v"`, u.symbol)
}
type environment map[symbol]interface{}
func (e environment) get(key symbol) (interface{}, error) {
v, ok := e[key]
if ok {
return v, nil
}
return nil, UnknownSymbolError{key}
}