Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit 2296c3b

Browse files
committed
feat: implement closures
1 parent 5d24ec5 commit 2296c3b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

models/object/closure.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package object
2+
3+
import "fmt"
4+
5+
type Closure struct {
6+
Fn *CompiledFunction
7+
Free []Object
8+
}
9+
10+
func (c *Closure) Type() string { return CLOSURE }
11+
func (c *Closure) Inspect() string {
12+
return fmt.Sprintf("Closure[%p]", c)
13+
}

models/object/object.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
EXPORT = "EXPORT"
1717
IMPORT = "IMPORT"
1818
COMPILED_FUNCTION = "COMPILED_FUNCTION"
19+
CLOSURE = "CLOSURE"
1920
)
2021

2122
type Object interface {

0 commit comments

Comments
 (0)