Here is a quick update on Red/System progress.
Draft has gone through several revisions. Several decisions mainly regarding pointers handling have been taken with simplification and disambiguation as main goals:
A couple of things to keep in mind about Red/System design:
Several items from the todo-list have been implemented in the last week, the most notable ones being:
Among other changes:
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:
In my next blog article, I will give an overview of Red/System compiler internals as requested by some followers.
I have published yesterday the first draft of Red/System’s specifications. It is amazing how much time and energy writing such formal description can take. It is a working draft, so expect it to be updated often during next weeks. The document source is in MakeDoc format and stored on github, so feel free to fix typos and errors directly there.
As all features in the specifications are not yet implemented (I would say 85% is already done), I have added a todo-list on github’s wiki to track the missing parts.
Also, all features are not yet set in stone, there are still a few important design decisions to take in the next weeks:
p: &[integer! 0] p/value: 123 p: struct [value [integer!]] p/value: 123
Looks pretty much the same. Pointers have a shorter literal form, but once declared, structs could be used the same way and replace pointers in all use-cases.
The answers to these questions will come while working on unit tests and coding Red’s runtime (written in Red/System). Feel free to share your thoughts about these features here, in comments, or on Google groups.