Jamison Creek – the latest version

I moved to a new 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, am 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 flavours 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 the 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 of 12 arrays of 3 numbers, which I think works well.

Structs use the same approach to block structure as complex statements, and they declare fields much like assignment declarations declare variables, so the initial value is optional. A simple example is
struct foo:
name:string="John Doe"
age:number=21
male:Boolean=True

which 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 declarations. `program` is now also a declaration at the same level. To flesh 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 operators which only evaluate the right hand side if the value is necessary to determine an 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 ensures the printed program runs correctly too,
  • ensures the printed program prints exactly the same as the original did, and
  • uses the gcc coverage support to track the fraction of interesting code lines that are being tested, and reports an 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,
  • further 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.

For now, you can read the current interpreter as Literate code.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


eight − 7 =

ERROR: si-captcha.php plugin says GD image support not detected in PHP!

Contact your web host and ask them why GD image support is not enabled for PHP.

ERROR: si-captcha.php plugin says imagepng function not detected in PHP!

Contact your web host and ask them why imagepng function is not enabled for PHP.