Description
BACKGROUND:
DrRacket uses a language's get-info function to set parameters such as
syntax coloring, indentation, and toolbar buttons. One parameter is
definitions-text-surrogate
1, which lets #lang
s set a surrogate
for DrRacket. The docs mention that this is a powerful, yet easy to do
wrong, IDE extension mechanism.
Unfortunately, as is, the definitions-text-surrogate
form does not
mix well with meta-languages e.g. s-exp, reader, at-exp. When given
the definitions-text-surrogate
key, get-info returns a single module
path for DrRacket to dynamic-require
. There is no way for a
meta-language to mix in its surrogate with the surrogate of the
language its extending. (At least not without either creating a
temporary file on the fly, or trying to scrape the current state of
DrRacket. Both of which are terrible ideas.)
PROPOSAL:
We extend the valid values for the definitions-text-surrogate
key to
be a list of symbols as well as a single symbol. In the case of a
single symbol, nothing changes.
In the case of a list, each element must also be a module path. The
last element must refer to a module that provides a surrogate%
class
as before. Every other element, however, refers to a module that
provides a surrogate%
mixin. The IDE constructs the expected
surrogate by traversing the list, each time dynamic-require
ing the
module, and mixing in the result. Meta-languages can augment existing
surrogates, rather than having to throw them away entirely. The
get-info
code for a meta-language might look something like this:
(make-meta-reader
...
(lambda (base-get-info)
(lambda (key default)
(case key
[(definitions-text-surrogate) (flatten (list
"meta-surrogate.rkt" (base-get-info key default)))])))
ENGINEERING EFFORT:
It looks like all of the changes would be confined to the following files:
drracket/drracket/drracket/private/in-irl-namespace.rkt
drracket/drracket/drracket/private/insulated-read-language.rkt
drracket/drracket/drracket/private/module-language-tools.rkt
(Obviously also documentation+tests)