Evaluation and REPL

This commit is contained in:
Chuck Smith
2024-01-20 08:30:34 -05:00
parent 44d20ba7a0
commit b76501c272
4 changed files with 80 additions and 19 deletions

20
object/environment.go Normal file
View File

@@ -0,0 +1,20 @@
package object
func NewEnvironment() *Environment {
s := make(map[string]Object)
return &Environment{store: s}
}
type Environment struct {
store map[string]Object
}
func (e *Environment) Get(name string) (Object, bool) {
obj, ok := e.store[name]
return obj, ok
}
func (e *Environment) Set(name string, val Object) Object {
e.store[name] = val
return val
}