blob: 7752ab4a54a38b63cbf55033a2af4565983c2dee (
plain)
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
|
context-specific namespace references
-------------------------------------
Context-specific namespace references are looked up in the namespace of the
type where they are used. Here are some example uses:
Common values for types and "defaults":
typedef PageSize = (float w h);
PageSize PageSize:A4 = (210, 297);
PageSize PageSize:USLetter = (215.9, 279.4);
PageSize:_ = :A4;
PageSize pg = :_; // _ is the "default"
Enumerations values:
typedef bool = (false=0, true=1);
bool a = :false;
() f(bool x);
f(:true);
TODO: How should default parameters be implemented? Can a special form of
context-specific parameters be used? For example:
() f(bool x);
meta f:x:_ = :false;
f(._); // access to f:x:_
// Note: We can access stuff outside the designated namespace!
// Is this a good idea?
Maybe it's better to have a special syntax:
() f(bool x=:false);
f(_);
|