[net.lang.lisp] Lisp Question

scott@gitpyr.UUCP (Scott Holt) (05/14/85)

   In certain dialects of lisp one can do the following...

 >  ( defun myfunction ( p-list ) ( eval body ) )
     myfunction

           then later

>   ( setq body '( car p-list ) )
     (car p-list)
>   ( myfunction '(a b c d))
     a

   and everything works fine....my questions is, are there any dialects of
   lisp where this wouldnt work, or not work the same?

                           A novice, but working on it, lisp programmer,
                                 Scott Holt
 
-- 
---------
"Its better to die on your feet than to live on your knees!"

Scott Holt
Georgia Tech Po Box 36199
Atlanta, GA 30332

...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!scott
...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!scott

massar@think.ARPA (J.P. Massar) (05/18/85)

In article <394@gitpyr.UUCP> scott@gitpyr.UUCP (Scott Holt) writes:
> >  ( defun myfunction ( p-list ) ( eval body ) )
>     myfunction
>
>           then later
>
>>   ( setq body '( car p-list ) )
>     (car p-list)
>>   ( myfunction '(a b c d))
>     a

In Common Lisp this will not work because the eval function evaluates
its argument in the null lexical environment (Common Lisp, p 321, Guy
Steele).  Since plist is only bound in the lexical environment of
myfunction this should result in an UNBOUND VARIABLE or similar error
instead of evaluating to 'a'.

In fact, using Kyoto Common Lisp this is exactly what happens.

-- 
-- JP Massar, Thinking Machines Corporation, Cambridge, MA
-- mit-eddie!godot!massar, ihnp4!godot!massar, massar@think, massar@cca-unix