a compiler for perl

Jecel Assumpcao Jr jecel@tunes.org
Fri, 19 May 2000 14:48:04 -0300


On Fri, 19 May 2000, Francois-Rene Rideau wrote:
> >: Jecel
> > Now the complex answer: depending on what reflective facilities a
> > language offers, the job of a compiler can become very hard indeed!
> > For example, programs in LISP have access to their own code and can
> > even change it while running.
> Well, depends on what LISP you're talking about (LISP 1.5 vs later),
> you don't modify the source code and have the behavior of functions
> explicitly change.

I was talking about directly changing the list representation of
functions, not the source (though they are equivalent). I know you
can't do that in Scheme, but I would be surprised if Common Lisp and
such don't have this capability.

Let me give an example in Logo ("Baby Lisp"):

   to randwalk
         left 45
         forward 5
         right 45
   end

   to changewalk
         local "x
         make "x text "randwalk
         define "randwalk lput (item random ((count :x) - 1)
                                                    (butfirst :x)) :x
   end

Every time you execute changewalk the proceedure randwalk gets extended
in a random way. You know, if Tunes was based on Logo it would start
out with a very large number of users :-)

> However, you can redefine and recompile functions,
> and evaluate expressions (that may be modified versions of earlier
> source code). Same with perl. In all these cases, the runtime contains
> a compiler or interpreter to satisfy the needs of eval users.

With runtime compilation (Self and Hotspot), we get the best of both
worlds!

> If the system makes it possible to detect that eval won't be used in
> a given program, then it might be stripped from a static binary output
> (some LISP "tree-shakers" are known to do that).

Just "grep eval source.lisp" and if the result is empty you know you
won't have to include the interpreter ;-)

-- Jecel