Interactive D?
Oskar Linde
oskar.lindeREM at OVEgmail.com
Sat Feb 23 01:24:22 PST 2008
bearophile wrote:
> Oskar Linde:
>> I got the idea to investigate the possibility of an interactive D
>> interpreter. A lazy afternoon of hacking resulted in a proof of concept,
>> and what follows is a short demo.
>> Could there be any interest in pursuing this?
>
> A interactive shell interpreter is very useful to learn the language, and to try little snippets of code before copying them into the code. Python and Scheme programmers do it all the time, and it's one of the advantages of those languages. So I think this may become quite useful.
> How does it work? Do you use the run-time compiler lib recently announced?
I don't use exe-lib. What Burton Radons has done is seriously impressive
and is a much bigger project than my small hack. I have constrained
myself to using the system built-in dynamic linking tools
(dlopen,dlclose et. al. or LoadLibrary/FreeLibrary on win32).
What the code does is basically creating some run-time d-code wrapping
the expression together with some helpers to feed data and type
information back and forth. It then compiles the generated code into
object code and transforms it into a dynamic library loadable with
dlopen. The generated library is then loaded, executed and unloaded
within the interpreters memory space.
The "import" statement compiles the corresponding .d source file and its
dependencies into one dynamic library per module, and then loads them
into the interpreter. If, at any time, a .d source file is changed the
corresponding module (and modules depending on that module) are
unloaded, recompiled and reloaded.
Burton's approach seems very interesting though. Not primarily speed
wise, since interactive speeds are enough for an interactive application
and a 50 ms delay compared to Burton's 1 ms is not very noticeable.
Instead, the major advantage of exe-lib is that it allows a much finer
control over library loading than the blunt dlopen/LoadLibrary. For
example, the possibility of having a callback resolving missing symbols
would be extremely useful.
--
Oskar
More information about the Digitalmars-d
mailing list