refactor objects
This commit is contained in:
@@ -54,17 +54,14 @@ func (t Type) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// Comparable is the interface for comparing two Object and their underlying
|
||||
// values. It is the responsibility of the caller (left) to check for types.
|
||||
// Returns `true` iif the types and values are identical, `false` otherwise.
|
||||
// Comparable is the interface for objects to implement suitable comparisons
|
||||
type Comparable interface {
|
||||
Compare(other Object) int
|
||||
}
|
||||
|
||||
// Immutable is the interface for all immutable objects which must implement
|
||||
// the Clone() method used by binding names to values.
|
||||
type Immutable interface {
|
||||
Clone() Object
|
||||
// Copyable is the interface for creating copies of objects
|
||||
type Copyable interface {
|
||||
Copy() Object
|
||||
}
|
||||
|
||||
// Object represents a value and implementations are expected to implement
|
||||
@@ -76,10 +73,9 @@ type Object interface {
|
||||
Inspect() string
|
||||
}
|
||||
|
||||
// Hashable is the interface for all hashable objects which must implement
|
||||
// the HashKey() method which returns a HashKey result.
|
||||
type Hashable interface {
|
||||
HashKey() HashKey
|
||||
// Hasher is the interface for objects to provide suitable hash keys
|
||||
type Hasher interface {
|
||||
Hash() HashKey
|
||||
}
|
||||
|
||||
// BuiltinFunction represents the builtin function type
|
||||
|
||||
Reference in New Issue
Block a user