This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Translators to guile



> In guile's home page it is stated that by linking to guile you'll be able to
> support other languages like CTAX.
> 
> I'm writing a JavaScript interpreter and I wish to write it in scheme. Where
> can I find specs and/or examples of the above?

CTAX is not the best example to emulate, for several reasons.

1) Its parser is implemented using some rather obscure techniques,
   based on regular expression hackery.
2) It implements a language very similar to Scheme, which means that 
   the translation is pretty direct.  If you're implementing a more
   distantly related language, then you will not learn much from Ctax.

So I think you'll do best simply by tackling the problem yourself.

I would suggest that, rather than writing a JavaScript interpreter in
Scheme, that you write a translator from JavaScript to Scheme.

Suppose Guile is N times slower than native code, and your JavaScript
interpreter is M times slower than Scheme code.  If you translate the
user's code into Scheme, then it runs N times slower than native code
(assuming you do a perfect translation).  If you write an interpreter,
then the user's code will run N*M times slower than native code.