Related articles |
---|
Using Prolog to Compile Things nickroberts@callnetuk.com (Nick Roberts) (1999-05-16) |
Re: Using Prolog to Compile Things gsg@mimuw.edu.pl (1999-05-20) |
Re: Using Prolog to Compile Things fjh@cs.mu.OZ.AU (1999-05-21) |
Re: Using Prolog to Compile Things bmd@cs.kuleuven.ac.be (1999-05-21) |
Re: Using Prolog to Compile Things anton@mips.complang.tuwien.ac.at (1999-05-22) |
Re: Using Prolog to Compile Things gkt37@dial.pipex.com (JT) (1999-05-22) |
Re: Using Prolog to Compile Things Daniel.Diaz@inria.fr (1999-05-22) |
Re: Using Prolog to Compile Things bmd@cs.kuleuven.ac.be (1999-05-27) |
Re: Using Prolog to Compile Things bromage@cs.mu.OZ.AU (1999-05-27) |
Re: Using Prolog to Compile Things hunk@alpha1.csd.uwm.edu (1999-06-02) |
Re: Using Prolog to Compile Things nickroberts@callnetuk.com (Nick Roberts) (1999-06-06) |
Re: Using Prolog to Compile Things guerby@acm.org (Laurent Guerby) (1999-06-12) |
From: | bmd@cs.kuleuven.ac.be (Bart Demoen) |
Newsgroups: | comp.compilers |
Date: | 27 May 1999 23:20:39 -0400 |
Organization: | BELNET (SSTC/DWTC) |
References: | 99-05-069 99-05-108 |
Keywords: | prolog |
> I can only conclude that prolog (which, incidentally, I do
> understand and can use properly, in its full declarative style) is
> either not appropriate for compiler writing, or I was doing
> something deeply wrong
With respect, I think you might have done something wrong: Prolog has
worked fine for too many people - also in compiler writing. My own
experience is this: in 1983 my boss wanted a Prolog compiler written
in Pascal (actually, Prolog to WAM code with optimisations); I wrote
it in Prolog first (although I was more familiar with Pascal at that
moment) in less than a month; then hand translated it to Pascal -
later to C. Since 1985, this compiler basically hasn't changed except
that features were added (inlining, register allocation, optimisation
of arithmetic, choicepoint reuse, improved unification ...) that were
all first modelled in Prolog in a couple of days before putting them
in C - and the Prolog code often stays in the C code as comment. This
compiler has not been really touched for 5 years now but is still part
of a commercial Prolog system with some big industrial users.
Maybe my experience contains for you also a proof that Prolog isn't
the right language to release a compiler in - opinions may vary there,
but I indeed belief that Prolog is best used for its prototyping
qualities.
Anyway, there might have been something wrong with the Prolog system you
had - you write:
> so got hold of a public domain version
...
> The main problem was the behaviour of prolog: a bug in my prolog, or
> the program I was trying to parse, both caused backtracks. Asserts
> didn't help. I'd even got to the point of considering asserting the
> current rule into the database so I could find out where it failed
> (a sort of audit trail).
This sounds like there was no decent debugger in your Prolog system.
But using asserts for debugging appears very weird to me as well - you
must have been desparate :-)
It is true that unanticipated backtracking in buggy Prolog programs
occurs and can be difficult to track down without the help of a
debugger, a methodology and/or experience. Typed logic languages make
this easier.
Bart Demoen
Return to the
comp.compilers page.
Search the
comp.compilers archives again.