Category: Update

Update on Red/System progress

17 April, 2011 | By Nenad Rakocevic

Here is a quick update on Red/System progress.

Specifications Draft

Draft has gone through several revisions. Several decisions mainly regarding pointers handling have been taken with simplification and disambiguation as main goals:

  • Struct! values are now passed by reference (a syntax for passing by value will be added in future), simple arithmetic (+, -) can be used on struct references.

  • String! was renamed to c-string! to avoid possible future collision with a Unicode-aware string! type. However, this case is not totally solved, there are still some possible issues, like the literal syntax. As c-string! values are passed by reference, simple arithmetic was added too.

  • Pointer! datatype was restricted to point to integer! values only. It is more consistent with new c-string! and struct! which are both (implicit) pointers already, and that removes the need for verbose pointer syntax.

  • Array! datatype: no decision taken for now, we will see if (both explicit and implicit) pointer arithmetic support will be sufficient during Red’s runtime implementation.

  • Logic! datatype was added as a first class type. This makes boolean literal values (true, false) and conditional expressions assignable to variables and can be passed as argument or returned by user functions. Logical NOT operator was also added as well.

  • Byte! datatype (unsigned byte value) was added to ease string byte accesses.

  • Limited type inference was added for function’s local variable and return value types.

A couple of things to keep in mind about Red/System design:

  • during the implementation of these specifications, some better design options might appear in light of the implementation decisions.

  • at some point, when the bootstrapping phase will be over, Red/System will be rewritten entirely in Red, giving an opportunity to fix and improve the design (also helped by several months of feedback from Red/System usage).

Implementation Progress

Several items from the todo-list have been implemented in the last week, the most notable ones being:

Among other changes:

  • ELF emitter has been extended a bit to support sections table (thanks to Andreas).

  • An experimental Mach-O (OS X) support is under work by Rebolek.

  • Several unit test files have been added to the repository recently, using a temporary minimalistic approach, that will be soon superseded by a real dedicated framework.

  • We are close to have a nice, small and lean unit test framework (Quick Test), created by Peter W A Wood for Red/System, covering all our needs (internal and external testing).

An interesting side note on how implementation can influence back the design:

During the implementation of Quick Test framework, Peter, while writing an integer to string conversion function, came up with a code pattern that is common in REBOL, but wasn’t planned for Red/System: declaring private functions inside a function to hide them from global context. The pattern looked like this:

prin-int: func [...][
    prin-digit: func [...][...]
    prin-digit ...

I was surprised when I tested the code he sent me, as I never did anything in the implementation to support such case explicitly. It was working because of a side-effect caused by the way functions are compiled in Red/System: the functions bodies are all gathered and compiled at the end of the global context code, regardless of where they are defined. The side-effect making the inner “prin-digit” function private is caused by a global function variable being declared inside a local scope, but without being part of the function specification block. So, once the outer function compiled, the “prin-digit” symbol is lost, making the function unreachable from global context and forever hidden.

I was thinking about adding a way for users to create private contexts much later in the future (relying on Red/System source header), but we have the opportunity to have an equivalent feature, right now and without adding anything to the code! So, I am giving it some time to see if the side-effect can be safely made permanent to keep that feature, and in the meantime, added it to the Possible Evolutions part of the specifications.

In the next days, I will work on:

  • finishing implementing the features from the todo-list
  • merging the unit tests framework once ready
  • adding new unit tests

In my next blog article, I will give an overview of Red/System compiler internals as requested by some followers.

Don’t just wait for new blog entries; join us on Gitter

Chat with the team, keep up with the latest design issues, and be part of a great community
Join Us
We're on a Mission to Fight Software Complexity Join us! →