]> ocean-lang.org Git - ocean-D/blob - Blog-JamisonCreek
updates
[ocean-D] / Blog-JamisonCreek
1
2 I moved home recently ... where "recently" is actually about 6 months
3 ago.  I'm using the extra demands on my time involved in buying a
4 house, packing up contents and unpacking at the other end, as an
5 excuse for not making progress on this project for a while.  But the
6 excuse if over, and coding has restarted.  I, at least, and happy
7 about that.
8
9 I've just tagged a new version - Jamison Creek - in honour of my new
10 home.  The main advance in this release is that types are starting to
11 take shape.  I had intended to implement various flavour of numbers -
12 integers and floats of various sizes - when I first did types, but it
13 didn't turn out that way:  they are actually rather complex as they
14 have subtleties that need to be worked out carefully.  I needed
15 something simpler to flesh out the infrastructure for types, so I've
16 just extended to current built-in types of "number", "string" and
17 "Boolean" with arrays and structs.
18
19 The syntax for declaring an array is different from what I proposed
20 earlier.  Had I used `[number:12]` for an array of 12 numbers, then an
21 array of 12 arrays of 3 numbers would have been `[[number:3]:12]`
22 which is ugly.  That could be fairly easily abbreviated as
23 `[numer:3:12]` but the indexes are backwards: the last element would
24 be `foo[11][2]`, which would be confusing.
25 So instead, arrays have the base type *after* the element count, and
26 that count is enclosed in brackets, so `[12][3]number` is an array ofr
27 12 arrays of 3 numbers, which I think works well.
28
29 Structs use the same approach to block structre as complex statements,
30 and they declare fields much like assignment declarations declare
31 variables, so the initial value is optional.  So:
32
33         struct foo:
34                 name:string="John Doe"
35                 age:number=21
36                 male:Boolean=True
37
38 can also be given as
39
40         struct foo { name:string="JohnDoe"; age:number=21;male:Boolean=True; }
41
42 These declaration are not part of code - in a `program` but come as
43 separate declaration. `program` is now also a declaration at the same
44 level.
45 To flex out these declarations we can also have `const` at the
46 declaration level
47
48 I've introduced a few new operators too: `and then` and `or else` are
49 short-circuit boolean operations which only evaluate the right hand
50 side is the value is necessary to determine and answer.  There is also
51 a trinary operator: `if ... else` which effects a conditional
52 expression.
53
54 As well as these language enhancements, I've added some proper
55 regression testing.  There are a collection of small sample programs
56 together with expected outputs, and a script that not only tests that
57 the output is correct, but also:
58
59 - uses valgrind to detect memory leaks
60 - prints the program and ensure the printed program runs correctly too
61 - ensures the printed program prints exactly the same as the original did
62 - Uses the gcc coverage support to track the fraction of interesting
63     code lines that are being tests, and reports and error if this
64     drops below a set threshold, currently 94%.
65
66 Hopefully it will be much less than a year before my next version is
67 tagged.  Some things I have planned for the next version are:
68
69 - Improved syntax error handling - particularly better messages and
70   better recovery.
71 - development of 'struct', at least anonymous fields
72 - a variety of numeric types
73 - more operators: >> << op=  ???
74 - pointers and memory allocation.  This will be the big change and
75   will probably get another blog post soon.
76
77
78 Stay tuned...