This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Scheme as an abstract syntax tree.
- To: Per Bothner <per at bothner dot com>
- Subject: Scheme as an abstract syntax tree.
- From: Jonathan Bartlett <johnnyb at wolfram dot com>
- Date: Mon, 10 Jul 2000 04:25:51 -0500 (CDT)
- cc: Nic Ferrier <nferrier at tapsellferrier dot co dot uk>, rms at gnu dot org, rm at mamma dot varadinet dot de, guile at sourceware dot cygnus dot com
I think the idea is that Scheme lists are a great representation of
abstract syntax trees. The reason why scheme is such a great language is
that it's code is the same as its data. So, you just have to have a parse
tree + some scheme special forms, and the scheme interpreter itself can
evaluate the code.
Jon
On 9 Jul 2000, Per Bothner wrote:
> "Nic Ferrier" <nferrier@tapsellferrier.co.uk> writes:
>
> > Translators for Guile into other languages have not been completed
> > yet but Scheme was chosen (AFAIK) because it is uniquely capable of
> > doing this.
> >
> > For example, Kawa (a GNU Scheme->Java-bytecode compiler) has
> > translators for EMACS Lisp and for ECMAScript (JavaScript).
>
> However, Kawa does not translate other languages in Scheme.
> Instead, Kawa translates other languages into an internal
> "abstract syntax tree" representation (similar to what Gcc does),
> and thence into Java bytecodes.
>
> This document http://www.gnu.org/software/kawa/internals.html
> describes how Kawa works. (It is a bit out of date, but should
> still be of interest.)
>
> > Scheme has an extendable syntax so it is easy to build new constructs
> > in the language, for non-LISP like languages one then has to simply
> > define a REPL for the language.
>
> But for some languages the semantics are so different from Scheme that
> it makes little sense to translate into Scheme. For example translating
> Prolog into Scheme you'd basically end up with Prolog with parentheses:
> some pretty strange Scheme, using special syntax forms that the compiler
> has to know about anyway if you want decent code.
>
> > The idea is, that when these translators are complete, you will
> > program in Guile/Python or Guile/Perl (or whatever) and not notice
> > that Scheme is actually doing all the work.
>
> But why? All it does is add an extra pass to slow down the compiler.
> The translated Scheme will in general not be human-reasonable, or
> useful for any purpose except as an intermediate language. In that
> case, might as well use an intemediate data structure more suitable
> for the compiler, as Kawa does.
> --
> --Per Bothner
> per@bothner.com http://www.bothner.com/~per/
>