builtins
This commit is contained in:
@@ -17,6 +17,7 @@ const (
|
||||
ERROR_OBJ = "ERROR"
|
||||
FUNCTION_OBJ = "FUNCTION"
|
||||
STRING_OBJ = "STRING"
|
||||
BUILTIN_OBJ = "BUILTIN"
|
||||
)
|
||||
|
||||
type Object interface {
|
||||
@@ -119,3 +120,16 @@ func (s *String) Type() ObjectType {
|
||||
func (s *String) Inspect() string {
|
||||
return s.Value
|
||||
}
|
||||
|
||||
type BuiltinFunction func(args ...Object) Object
|
||||
|
||||
type Builtin struct {
|
||||
Fn BuiltinFunction
|
||||
}
|
||||
|
||||
func (b Builtin) Type() ObjectType {
|
||||
return BUILTIN_OBJ
|
||||
}
|
||||
func (b Builtin) Inspect() string {
|
||||
return "builtin function"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user