This repository has been archived by the owner on Jan 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
98 lines (78 loc) · 1.34 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package gelo
type Word interface {
Ser() Symbol
Copy() Word //these two should be in a MutableWord interface since
DeepCopy() Word //a lot of the intrinsic types are immutable
Equals(Word) bool
Type() Symbol
}
type Symbol interface {
Word
Bytes() []byte
Runes() []rune
String() string
interned() bool
}
type Quote interface {
Word
unprotect() *quote
}
type Port interface {
Word
Send(Word)
Recv() Word
Close()
Closed() bool
}
type Error interface {
Word
error
From() uint32
_tag()
}
type Bool bool
type Number struct {
num float64
ser []byte
}
type List struct {
Value Word
Next *List
}
type Dict struct {
rep map[string]Word
ser []byte
}
type Alien func(*VM, *List, uint) Word
func (a Alien) Ser() Symbol {
return a.Type() //we hope some day that reflection can get the name of a
}
func (a Alien) Copy() Word {
return a
}
func (a Alien) DeepCopy() Word {
return a
}
func (a Alien) Equals(w Word) bool {
return false
}
func (Alien) Type() Symbol {
return interns("*ALIEN*")
}
//defined at the top of vm.go as it is a special internal tag
func (d *defert) Ser() Symbol {
return d.Type()
}
func (d *defert) Copy() Word {
return d
}
func (d *defert) DeepCopy() Word {
return d
}
func (*defert) Equals(w Word) bool {
_, ok := w.(*defert)
return ok
}
func (*defert) Type() Symbol {
return interns("*DEFER*")
}