]> ocean-lang.org Git - ocean-D/blob - Abstract Syntax
updates
[ocean-D] / Abstract Syntax
1
2 Hiding behind the concrete syntax there is an abstract
3 syntax which embodies all the important concepts without
4 being distracted by sugar.
5
6 A core concept is object method calling.
7 The actual function is determined from the concrete type of the first
8 argument.
9 So the method call takes a list of objects from local names and
10 returns a list of objects which are associated with local names.
11
12   (a,b,c) = z.Function(x,y,z)
13
14 The formal args of the function may end in @rest which causes extra args to
15 be placed in a vector.  Alternately a vector can be passed as @v.
16
17 Maybe the list is just part of the concrete syntax.
18 A function (like an object) has a set of internal names.
19 A function call involves:
20   Setting some internal names
21     Executing the code
22   retrieving some internal names.
23 So it is like
24    fn = New obj.method
25    fn.a=b; fn.b=a; ...
26    Call fn;
27    p=fn.z; q=fn.y;
28
29 Note that 'fn' is a concrete object and we know how to
30 access the various feels directly - they are not accessor function.
31
32 if/while/switch/etc become if/goto.  If the given name is not false,
33 control is tranferred to the label.  A distinguished label effects 'return'
34 Constants... get assigned names in the function preamble.
35
36
37 Objects can be:
38   refcounted  - freed when refcount hits zero
39   'once' - copied when refcount would become 2.
40
41 Also, objects can be dependant on some other object.  In that case,
42 references within the dependancy group are not counted, and references from
43 outside effect the whole group.
44 This is particularly useful when objects are attached to function calls