]> ocean-lang.org Git - ocean-D/blob - Ocean-operators
updates
[ocean-D] / Ocean-operators
1
2 Operators.
3 I currently have
4
5 Binary: and or < > <= >= == !=  + - * / % ++
6 prefix: not + -
7
8 I might want:
9
10  Binary: and then, or else, integer division
11  Prefix: int
12  Suffix: dereference
13
14
15  Do I want  COND ? IFTRUE : IFFALSE
16    or       IFTRUE if COND else IFFALSE
17
18   Can    / NUMBER
19    provide the integer part?
20
21  What can I use '!' '@' '#' '$' '^' '&' '*' '|'
22    for
23
24  bit-wise and/or/not/xor
25
26     != is 'xor' for Boolean
27
28  I should use & | ~ for bitwise. and or not
29     ~ could be an infix for xor
30     &~  could clear bits
31
32  What foo= options?
33    += -= *= /= %= &= |= ~=
34
35  Do I want "#n" to be (1 << n) ??
36
37  ++ is concat.  What about
38     --
39     **
40     // - comment
41     @@
42     ^^
43     &&
44     ||  These last two are best avoided.
45
46  Pointers ... do I need a dereference operator?
47   Normally a pointer refers to the object it references (which isn't a pointer)
48    The only difficulty is
49           a = b
50    If a:foo and b:foo^  then b is dereferenced.
51    If a:foo^ and b:foo  then a points to b
52    if a:foo^ and b:foo^ then a points to what b points to
53
54    So how do you change what a points to?  I could have a de-reference operation
55       *a = b;  a^ = b
56    but I think I want a structure-changing assignment
57       a @= b
58    then maybe
59       a @@= b
60    does a deep copy
61
62 What types do operators act one?
63
64    numbers  + - * / %
65    bitsets  & | ~ &~
66    Boolean  and or not "and then" "or else" "if .. else"     What about and= ??  *= ??
67    string   ++  < > == etc,  regexp? strlen? append?
68    character?  add to string?  Convert to string?
69
70
71    What about error encoding?  e.g. a pointer can have nil or other error encoded
72    A range-limited number could have extra codes outside that range.
73    Need to be able to :
74       convert error to type     !error
75       test if value is error    ?value
76       extract error code        value!