[RPL/2] self compiling ?

BERTRAND Joël joel.bertrand at systella.fr
Sam 17 Nov 09:54:07 CET 2007


DEMAINE Benoit-Pierre wrote:
> Adrian Blake wrote:
>> What I would like is an example of how it is done.
> 
> Bertrand asked you what you want.
> 
> And, you should email me; you should email the list. Otherwise, the
> replyto get shuffled.
> 
>> It is easy to create a text file of source code and then issue some
>> system commands to compile and execute. If this is to be done many times
>> most of the time and resources is spent with system commands and
>> compiling. This is especially true if the programs are small and there
>> are many to be recompiled many times.
>>
>> Can RPL/2 do this in a simple manner?
> 
> Which langage do you use as generator ?
> what do you want to generate ?
> from where ?
> 
> what I did on HP48 was ... the only thing that is possible on this
> machine: use RPL to generate RPL.
> 
> But, on a PC, you can go way further, like, use Perl to generate RPL,
> test it as RPL, then ask the interpreter to generate C code for it, and
> them querry GCC to optimise the code ...
> 
> RPL/2 can generate C from RPL, or directly produce a system executable
> file (that is likely to be linked with some RPL library)

	No it cannot.

	You can add some external functions written in C (or with all languages 
that acceots C-type calling procedure). Have a look in 
src/rplexternals.h and examples/*.rplc. rplc compiler uses macro 
instructions (over gcc) to produce a regular shared object usable by 
RPL/2 (loadable by USE intrinsic). If you use librpl, you can launch a 
RPL/2 _interpreter_ inside a C program (or all languages that uses C 
calling procedure), but you don't generate any compiled program.

>> There is a programming language called Erlang which allows the
>> programmer to modify and add to the executing code. The allows
>> continuous upgrades without stopping the program.
> 
> RPL as conveived by HP was not designed to allow "on the fly self
> modifiable code". And I dont think PC implementation by Bertrand
> improoves this aspect in any maner.

	There is two interpreters in ony program ;-) A text script is evaluated 
by sequenceur() and an expression is evaluated by evaluation(). A text 
script is static (because it's half-compiled and some verifications are 
made before starting execution), but an expression can be dynamic and I 
think it is possible to write some new intrinsics to modify a running 
evaluation. I never use this type of features and I don't have any idea 
about it. Thus, if you have an example...

> Stil, from within RPL, a program can generate other programs, call them,
> stop itself ... Bertrand also implemented some labels that will allow
> special jumps: put a condition at the beginning, and perform
> conditionnaly a GOTO thing. Still, you will have stack problems.

	I have implemented some labels ? Example, please ;-)

> But, maybe Bertrand introduced some features that would allow some kind
> of workaround ... if you have used assembly on micro architectures, and
> if Bertrand did some kind of program counter/pointer, then, you may have
> lot of fun around it :)

	Regards,

	JKB


Plus d'informations sur la liste de diffusion RPL2