This is the mail archive of the guile@sources.redhat.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: Scheme as an abstract syntax tree.


Jonathan Bartlett <johnnyb@wolfram.com> writes:

> I think the idea is that Scheme lists are a great representation of
> abstract syntax trees.

But they are not.

> 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.

An interpreter is not interesting.  What you want (well, what I want)
is a compiler.  And a compiler needs to annotate various pieces of the
abstract syntax tree with flags, pointers to defining occurrences,
line number in the source file, etc.  Of course these can all be
implemented using lists.  It is just that the resulting lists no
longer look like Scheme source code, so you might as well use a more
compact and efficient structure.

I'm not saying you can't implement other languaes by compiling to Scheme.
Of course you can.  I just think the result will be poor.

There is a lot of experience with compiling a number of languages
to a shared abstract syntax tree format (Gcc, Kawa, ...) and we know
it works.  There is much less experience compiling other languages
into other source languages.  The only language that has been extensively
used as a compilation target is C, and that is because C is viewed as
"portable assembler".  In general, using C as an intermediate language
causes uncomfortable compromises, and is little in favor these days.
(No-body writes C++ compilers that translate to C anymore.)  The main
reason people translate into another language is because compilers for
the second language are widespread.  That is not an issue with Scheme:
Translating into an internal abstract syntax tree will be just as
portable as translating into Scheme, and both faster and better.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

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