From: NeilBrown Date: Sat, 18 May 2019 21:20:35 +0000 (+1000) Subject: updates X-Git-Url: https://ocean-lang.org/code/?p=ocean-D;a=commitdiff_plain;h=1f0084c0240616f86aada2c7331f13fe6a6a43bc updates Signed-off-by: NeilBrown --- diff --git a/00-TODO b/00-TODO index b89cc9f..9af0d5c 100644 --- a/00-TODO +++ b/00-TODO @@ -1,16 +1,10 @@ This is a living document - delete things when done. Avoid discussion. -NOW: + +Current version (?? Creek) - handle free_type more cleanly?? - rethink line-like parsing. Should element also start a line? - review simple/complex parsing options in various situations - -Current version (Jamison Creek) - - clean up - -Next version ?? -- spaces in numbers -- # not comment?? - automatic if used as a mark. - can I move 'ok' into the parse context? Then error functions can set it. - allow something so I don't need to call config2context so often Some code stanza to be added to do_reduce() @@ -39,6 +33,8 @@ Next version ?? - allow "do stuff" as a stand-allow statement (scope) +Next version: + Much later - functions and procedures diff --git a/Blog-JamisonCreek b/Blog-JamisonCreek new file mode 100644 index 0000000..b2bd53b --- /dev/null +++ b/Blog-JamisonCreek @@ -0,0 +1,78 @@ + +I moved home recently ... where "recently" is actually about 6 months +ago. I'm using the extra demands on my time involved in buying a +house, packing up contents and unpacking at the other end, as an +excuse for not making progress on this project for a while. But the +excuse if over, and coding has restarted. I, at least, and happy +about that. + +I've just tagged a new version - Jamison Creek - in honour of my new +home. The main advance in this release is that types are starting to +take shape. I had intended to implement various flavour of numbers - +integers and floats of various sizes - when I first did types, but it +didn't turn out that way: they are actually rather complex as they +have subtleties that need to be worked out carefully. I needed +something simpler to flesh out the infrastructure for types, so I've +just extended to current built-in types of "number", "string" and +"Boolean" with arrays and structs. + +The syntax for declaring an array is different from what I proposed +earlier. Had I used `[number:12]` for an array of 12 numbers, then an +array of 12 arrays of 3 numbers would have been `[[number:3]:12]` +which is ugly. That could be fairly easily abbreviated as +`[numer:3:12]` but the indexes are backwards: the last element would +be `foo[11][2]`, which would be confusing. +So instead, arrays have the base type *after* the element count, and +that count is enclosed in brackets, so `[12][3]number` is an array ofr +12 arrays of 3 numbers, which I think works well. + +Structs use the same approach to block structre as complex statements, +and they declare fields much like assignment declarations declare +variables, so the initial value is optional. So: + + struct foo: + name:string="John Doe" + age:number=21 + male:Boolean=True + +can also be given as + + struct foo { name:string="JohnDoe"; age:number=21;male:Boolean=True; } + +These declaration are not part of code - in a `program` but come as +separate declaration. `program` is now also a declaration at the same +level. +To flex out these declarations we can also have `const` at the +declaration level + +I've introduced a few new operators too: `and then` and `or else` are +short-circuit boolean operations which only evaluate the right hand +side is the value is necessary to determine and answer. There is also +a trinary operator: `if ... else` which effects a conditional +expression. + +As well as these language enhancements, I've added some proper +regression testing. There are a collection of small sample programs +together with expected outputs, and a script that not only tests that +the output is correct, but also: + +- uses valgrind to detect memory leaks +- prints the program and ensure the printed program runs correctly too +- ensures the printed program prints exactly the same as the original did +- Uses the gcc coverage support to track the fraction of interesting + code lines that are being tests, and reports and error if this + drops below a set threshold, currently 94%. + +Hopefully it will be much less than a year before my next version is +tagged. Some things I have planned for the next version are: + +- Improved syntax error handling - particularly better messages and + better recovery. +- development of 'struct', at least anonymous fields +- a variety of numeric types +- more operators: >> << op= ??? +- pointers and memory allocation. This will be the big change and + will probably get another blog post soon. + + +Stay tuned...