Everything is a closure
This commit is contained in:
@@ -22,7 +22,8 @@ const (
|
||||
BUILTIN_OBJ = "BUILTIN"
|
||||
ARRAY_OBJ = "ARRAY"
|
||||
HASH_OBJ = "HASH"
|
||||
COMPILED_FUNCTION_OBJ = "COMPILED_FUNCTION_OBJ "
|
||||
COMPILED_FUNCTION_OBJ = "COMPILED_FUNCTION"
|
||||
CLOSURE_OBJ = "CLOSURE"
|
||||
)
|
||||
|
||||
type Object interface {
|
||||
@@ -235,3 +236,16 @@ func (cf *CompiledFunction) Type() ObjectType {
|
||||
func (cf *CompiledFunction) Inspect() string {
|
||||
return fmt.Sprintf("CompiledFunction[%p]", cf)
|
||||
}
|
||||
|
||||
type Closure struct {
|
||||
Fn *CompiledFunction
|
||||
Free []Object
|
||||
}
|
||||
|
||||
func (c *Closure) Type() ObjectType {
|
||||
return CLOSURE_OBJ
|
||||
}
|
||||
|
||||
func (c *Closure) Inspect() string {
|
||||
return fmt.Sprintf("Closure[%p]", c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user