April 17, 2011

Update on Red/System progress

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.


  1. Great Work Doc!. Keep the updates coming. Nice to get to see how RED/System is evolving.


  2. Thank you for your kind support Paul.

  3. Test anonymous comment for wet_wet_wet (see thread on RebelBB forum).


  4. Try to preview comment.

  5. what about osx version?

  6. The OSX port is under work by Rebolek, last time I have heard of him, he had some issues with the Mach-O file format. I didn't had the time to give a deep look at it yet. I hope to be able to do that in the next days.

  7. [retrying one more time to post]
    thanks for all the effort you are putting in, I sincerely hope that it pays off big time in the near future.

    could you publish your roadmap and also the related milestones, so that we can follow you better.


  8. Hi wet_wet_wet,

    You can find a brief roadmap and milestones only slide 17 from the presentation here: http://www.red-lang.org/2011/02/journey-begins.html

    I will try to copy it somewhere else to make it easier to find.

  9. Test anonymous comment for RebKodeur (see thread on RebelBB forum).


Fork me on GitHub