type checking and error handling for builtins improved.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package object
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Type represents the type of an object
|
||||
type ObjectType string
|
||||
|
||||
@@ -25,6 +27,13 @@ type Comparable interface {
|
||||
Compare(other Object) int
|
||||
}
|
||||
|
||||
// Sizeable is the interface for returning the size of an Object.
|
||||
// Object(s) that have a valid size must implement this interface and the
|
||||
// Len() method.
|
||||
type Sizeable interface {
|
||||
Len() int
|
||||
}
|
||||
|
||||
// Immutable is the interface for all immutable objects which must implement
|
||||
// the Clone() method used by binding names to values.
|
||||
type Immutable interface {
|
||||
@@ -34,8 +43,9 @@ type Immutable interface {
|
||||
// Object represents a value and implementations are expected to implement
|
||||
// `Type()` and `Inspect()` functions
|
||||
type Object interface {
|
||||
fmt.Stringer
|
||||
Type() ObjectType
|
||||
String() string
|
||||
Bool() bool
|
||||
Inspect() string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user