-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathideas.txt
208 lines (172 loc) · 5.27 KB
/
ideas.txt
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
Based on agent, action, target
Distinguish "own" state vs "external" properties:
- color and length are internal
- position is an external property
- size is external: it is a function of internal state and can take many forms (fuzzy, exact, etc)
- this allows properties to be added
- modification of internal property can be guarded in the usual way (define an action for the property)
Basic types:
- object (a sequence of one)
- sequence of objects (a tree with one branch)
- tree of objects (a directed network with one root and each node has only one parent): it has branches, inner nodes, leaf nodes, rows
- network of objects
- a table is a sequence of sequences
- a table is also a tree of branches of same length, where branches represent columns
Object, also [] empty network/tree/sequence/None
Sequence:
[object1, object2, ..., objectN]
or [object1 -> object2 -> object3 -> ... -> objectN] (column)
or (object1, object2) tuple (static content and length)
many object = True only if object is a non-empty sequence
Tree:
root object:
object 1:
object 1.1
object 2:
object 2.1
object 2.2
object 2.2.1
object 2.2.2
object 2.3
object 3
or [root object -> [
object 1 -> object 1.1,
object 2 -> [
object 2.1,
object 2.2 -> [object 2.2.1, object 2.2.2],
object 2.3
],
object 3
]
Network:
[
object 1 -> [
object 1.1,
object 2.1,
object 2.2.2
]
object 2 -> [
object 2.1,
object 2.2 -> [object 2.2.1, object 2.2.2],
object 2.3 -> object 1
],
object 3 -> object 1
]
class House:
actions:
open door:
change own state
interact with target(s)
interact with environment (globals -- such as interpreter, filesystem, network, timer)
context sensitive (there is a default "always" context)
return object(s)
...
class Foor
property bottom of (many Floor):
first of (many Floor)
property top of (many Floor):
last of (many Floor)
own state:
floors: list of [Floor, Floor, Floor]
door: Door bottom-of-floors
window
...
...
# external property:
property size of House:
choose:
big: radius > 5
small: radius < 2
gray: else
# external property:
property radius of House:
cuberoot of ((length * height * width) of House / (width * height) of Window)
define position of House:
fpv x = x of House
fpv y = y of House
fpv z = z of House
class radian extends fpv
define orientation of House:
fpv zrot
fpv yrot
fpv xrot
define power(exponent) of position:
x^exponent + y^exponent + z^exponent
define position(Relative, Observer) of House:
beside:
dir_to_house = position of House - position of Observer # infers dir is fpv
dir_to_rel = position of House - position of Relative # infers dir is fpv
distance = square_root of (dir_to_house - dir_to_rel)^2
... # determine if too far behind or in front of, to be considered beside
choose from a = (radius of House) / distance,
b = (radius of Relative) / distance,
c = too_far_or_near:
too_far_or_near is true: no
a + b ~= 1: yes
otherwise: no # this is optional, as it is the "pass through" result
under:
...
above:
...
in_front_of:
...
behind:
...
inside:
...
define dusty of House:
choose:
yes: dust of House > 5
define funcName of args:
do stuff
conditional return objects
do more
last expression returns object, if caller asked for it
define sqrt of (a, b):
...
a = funcName(args) # call funcName
funcName(args) # don't care about return, just side effects
house = new House(a, b, c)
house2 = house # reference
unset house
dispose house2 # unsets and calls its finalizer
houses = many House # empty sequence
set_of_houses = set(houses) # create a set from the houses
list_of_houses = list(houses) # create a doubly linked list
tuple_of_houses = tuple(houses) # create const array
a, b = 1, 2 # infer a, b are int
a = 'asdf' # error: type cannot change
class A:
extends B
own state:
a=2 # overrides values in B
a = new B # infer that type of a = B
a = new A # ok because A derives from B, so it is more specific
b = new A # infer that type of b = A
b = new B # error because B is not a specialization of A
sel_houses = houses where:
(x, y) of position of houses > (3, 3) # same as [h for h in house if h.x > 3 and h.y > 3]
# this creates a sequence of booleans
far_houses_test = (x, y) of position2 of houses > (3, 3) defined with:
position2:
position of house - 1
define far_house of House:
choose:
true: (x, y) of position of House > (3, 3)
define far_houses of (many House):
each of ( (x, y) of position of (many House) > (3, 3) ) is true
explore definition using : instead of = to disambiguate equality vs definition
a: new B
b: a
class A:
extends B
override B.a: # completly hide all definitions of B.a
overload B.a(a, b, c): # add a definition of B.a to A
....
if a is b
if (a: b + c) > 2:
if (a: b + c) >= 2:
if (a: b + c) > 2:
if (a: b + c) ~= 2 within 0.04: # absolute within
if (a: b + c) ~> d within (4%, rel=true): # relative within
if a = b: