From: S.N.K.Wat (Stuart Watt [at home])

Subject: Re: Problem (?) with evalhook

Date: 1997-4-28 17:02

Actually, there isn't an interpreter at all in Allegro CL for Windows, and
never has been. Many of the "smaller" (in fact, practically all non-UNIX)
Common Lisp implementations don't have an interpreter, or a complete
interpreter, at all. They simply compile the forms you type in and then run
the code; eval simply calls compile. If the compiler's fast, the effect is
still instant.

CLtL2 makes strenuous efforts to ensure that it *doesn't* assume you've got
a complete interpreter -- that's why all the stuff on constant folding is
there. Code should work identically independent of whether it's compiled ot
not, and this isn't possible with evalhook. Unfortunately, you can't
implement evalhook sensibly without an interpreter, so I guess this just
slipped through the net at the time, so I wouldn't count on its existence
much.

In fact, evalhook sometimes isn't all that useful anyway. This is because
you can't actually do accurate stepping without knowing quite a lot about
Common Lisp special forms. For example:

(let ((a (+ 1 2))
      (b (+ 1 2)))
  (+ a b))

There are two forms (+ 1 2), and they're both evaluated in the context of
the let, but according to Common Lisp, there's no way of knowing which form
is being evaluated on which call to evalhook. So writing any good stepper
or tracer means you need to know all about how let works anyway, and
evalhook hasn't helped much.

Solutions?

1. Write a portable Common Lisp interpreter. I've been wanting to do this
for years, but have never found the time. And somebody once told me (I
think) it was voted out by ANSI. Anyway, if you really need a complete
stepper, this is probably the only portable solution.

2. Use a code walker to "annotate" the forms before they are evaluated.
There is a portable (ish) code walker at the CMU AI archive, which can
probably be used for this. Tedious (a lot less tedious than 1 above) but
viable.

3. Try to get the source code for the Allegro CL for Windows stepper, and
adapt it. Not really ideal because it's not portable, but it may well work.


Regards, Stuart

>>Hi, I am trying to get the following piece of code to run in Allegro CL 3.0. >>It was taken from the common lisp manual. >> >>http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/misc/mosaic/common/omega/Web/Groups >>/AI/html/cltl/clm/node180.html >>
>[schnipp]
>> >>According to the manual it should behave like this: >> >>(hook '(cons (floor *print-base* 2) 'b)) >> Form: (CONS (FLOOR *PRINT-BASE* 2) (QUOTE B)) >> Form: (FLOOR *PRINT-BASE* 3) >> Form: *PRINT-BASE* >> Value: 10 >> Form: 3 >> Value: 3 >> Value: 3 1 >> Form: (QUOTE B) >> Value: B >> Value: (3 . B) >>(3 . B) >> >>Instead Allegro 3.0 returns: >> >>(5 . B) (with out printing any messages) >> >> >>Does anybody know why this won't work? >> >>thanks, >> >>Lael
> >I think you're confronted with several problems ;-) : > >1.) It looks like you have a code-modifying compiler: > You entered ... (floor *print-base* 2) .... > but evaluated is (FLOOR *PRINT-BASE* 3) > ^^^^!!!! > That explains the different results. It's a printing error in CLtL2. > >2.) As far as I know, the evalhook will be only used, when your Lisp is in >interpreter mode, that means, if your code is not compiled. I suppose that >all modern Lisp environments which have both an interpreter and a compiler >are set to compiler mode per default. I don't know the ACL environment for >UNIX but look for a global variable similar to *compile-definitions*. > >3.) Although evalhook and applyhook are mentioned in CLtL 2nd edition, I >read that X3J13 voted to remove these guys from the standard ..... >I don't know if it's worth experimenting with them if the next release will >skip them. > > >- stefan > >______________________________________________________________________________ >Stefan K. Bamberger email: <informatik.uni-wuerzburg.de at bambi> >Lehrstuhl fuer K"unstliche Intelligenz fax : ++49 931 7056120 >Allesgrundweg 12, 97218 Gerbrunn voice : ++49 931 7056118 > Universit"at W"urzburg, Germany >______________________________________________________________________________
================================================================== Stuart Watt; Knowledge Media Institute and Department of Psychology Open University, Walton Hall, Milton Keynes. MK7 6AA. UK. Tel: +44 1908 654513; Fax: +44 1908 653169 WWW: http://kmi.open.ac.uk/~stuart/stuart.html