]> ocean-lang.org Git - ocean-D/blob - Ocean-functions
updates
[ocean-D] / Ocean-functions
1 I want to add functions and procedures soon.  I should decide on syntax at least.
2
3 The args to a function are effective a struct, so I want it to look the same.
4 C doesn't allow "int a, b, c" in the parameters, which I think is clumsy.
5 struct can be
6
7   struct name:
8      a,b,c:number
9      d:string
10
11 So function might be
12
13    func name:
14        arg1, arg2: type
15        arg3: type2
16    returns type
17    do:
18         stuff
19
20 A procedure is different as it doesn't have just a return type,
21 it has a return structure.  So many C functions have 'ret' or 'result'
22 variable that it might be nice to follow the Pascal approach of
23 assigning to the function name??  or having
24
25     func name:
26        args:types
27     returns:
28        results:types
29     do:
30        statements
31
32 A shorter version would be
33
34     func name(args:types;args:types):type { }
35 or
36     proc name(args:types;args:types):(result:type;...) {}
37