Update on Progress Towards Parable 1.0

Work on Parable has been progressing smoothly. At this point many bugs have been found and fixed, the new type system is in place and working, and the various interface layers have been updated to work with the changes.

So what's next?

I have a few things to finish up on the Apologue update:

  • The new internals browser is about half complete.
  • The documentation is seriously out of date.
  • The included examples are broken.

I'll be addressing these shortly. I have corrected examples, but haven't updated them yet since the standard library will be seeing more changes in the near future as work to finalize it progresses. For the documentation, I'm in the process of rewriting everything. This should be done near the end of the month. And on the internals browser, it's not 100% finished, but it's significantly better than the one in 1.7.

With the upcoming shutdown of iTunes Connect I would like to get this done before the holiday. So my current plan is to remove the old documentation, replacing it with the new (but not 100% complete) docs and update the examples. The internals browser should be finished this week, so if all goes well I'll be submitting 1.8 for review early next week. I'll then push smaller updates to incorporate further documentation updates.

For the core code, I'm pretty much happy with it. There's a good chance that I'll be doing some refactoring of it next year, but there's some other work to be done first.

The biggest thing remaining is the standard library. Everything in it is functioning, but not documented, and I'm not satisfied with all of the naming choices. I'll be working on this quite a bit over the next few weeks.

So the todo on the standard library is:

  • Ensure all stack comments are up to date
  • Finalize naming conventions, renaming functions to match
  • Remove non-essential functions, add useful new ones

I will try to finalize the naming conventions next week. Once this is done, the rest should progress pretty quickly.

when: a conditional combinator

One of the new combinators in Parable is when. This is intended to allow for quickly checking multiple conditions. Effectively providing an if/elseif/else structure.

As an example, we can replace something like:

"value - string"
type? NUMBER = [ drop 'value was a number' ] \
[ type? STRING = [ drop 'value was a string' ] \
    [ drop 'did not match type, sorry!' ] if ] if


"value - string"
[ \
  [ [ type? NUMBER = ] [ drop 'value was a number' ] ] \
  [ [ type? STRING = ] [ drop 'value was a string' ] ] \
  [ [ true ] [ drop 'did not match type, sorry!' ] ] \
] when

When takes a set of nested quotations. The top level contains subquotes which themselves contain pairs. The first item in each pairing is a test, the second is the code to be executed if the test returns true.

While I don't expect to use this often, it is nonetheless a valuable addition to the language. I can see it being very useful when working with custom types, and in a few larger applications I have in mind.

Garbage Collection in Parable

While working on adding the new type system to Parable I decided to rewrite the garbage collector. This has finally fixed some longstanding issues and will be very beneficial going forward.

The previous garbage collector was very simple: it scanned all named slices, appending all values they contained as probable references. Anything not in this set was then released. There were a few issues:

  • Without type information a lot of unneeded slices were being kept
  • The code to find references didn't always follow all dependent chains, so some neccessary slices were being discarded
  • Pointers on the stack were not scanned

These issues led to a number of bugs, and prevented me from making good use of the garbage collector. With the addition of type information it became possible to resolve these issues, and make it into a fully functional part of the language.

So the new approach is:

  • Scan all named slices for strings, comments, pointers, and function calls
  • Scan all references to pointers and function calls for the above types. Repeat until all nested references have been scanned
  • Repeat the above process for all values on the stack
  • Remove any duplicates
  • Release any allocated slices that are not in the above set

At this point everything is working. I haven't completely tested it, but it's certainly more stable than the previous implementation. Further work on this will be done as necessary, but for now I'm moving onto other tasks.

Revising the Parable Memory Model and Virtual Machine

I was nearly done. Parable (in the repository) was pretty stable, and I was nearing completion of the initial standard library. But recent events have prompted me to delve deep into the code again, making further changes to the entire underlying code.

Currently Parable is based on a heavily extended model derived from my work on Retro and Toka. It uses sliced memory and garbage collection like Toka (but with dynamic sizing of the slices), and a byte coded virtual machine like Retro. This works, but the big downside is that the Parable language supports types on the stack, but does not save them when storing. This becomes an issue in that the user needs to manually track and restore types when storing and fetching data.

I'm going to fix this. I'm adding a secondary set of slices which will shadow the data slices, storing the type information for each element. When I'm done, this will allow a bunch of benefits. The biggest ones for me are probably:

  • all quotations will be treatable as data structures
  • arrays, variables, etc will all store the types for each element stored
  • less code noise, since the user will no longer need to restore types when working with data stored in memory

I'll also be changing the parser a bit. It'll allow for numbers without the # prefix. After extensive use of Apologue with the "numbers without prefixes" option, I've decided that the convenience of using numbers directly is worth the slight tradeoffs.

I will probably push out one more interim Apologue release to fix bugs in the released version. Since the changes I'm making now are going to be extensive, I can't see holding up the bugfix release any longer. I won't be running a new beta of Apologue until the backend changes are completed.

Work on this has begun. To follow development, check the main Parable page and get a copy of the git repository.