[comp.lang.lisp] Question about eval

dfried@iuvax.cs.indiana.edu (Dan Friedman) (10/11/88)

Are there any LISP implementations, especially of Common LISP,
which get 5 instead of 1 as the result of the following run?

>>> (defun eval (x) 1)
eval

>>> 5
1

Does this change to eval ever change what load does?

Does (setf (symbol-function 'eval) #'(lambda (x) 1))
do exactly the same thing as (defun eval (x) 1) in all 
Common Lisp implementations?

... Dan

lou@bearcat.rutgers.edu (Lou Steinberg) (10/11/88)

In article <13733@iuvax.cs.indiana.edu> dfried@iuvax.cs.indiana.edu (Dan Friedman) writes:

> Are there any LISP implementations, especially of Common LISP,
> which get 5 instead of 1 as the result of the following run?
> 
> >>> (defun eval (x) 1)
> eval
> 
> >>> 5
> 1

Yep - I just tried it in Allegro common lisp (from Franz Inc) on my
sun-3 and got just that.

Looks like something to remember for next April 1 ... :-)
-- 
					Lou Steinberg

uucp:   {pretty much any major site}!rutgers!aramis.rutgers.edu!lou 
arpa:   lou@aramis.rutgers.edu

eliot@phoenix.Princeton.EDU (Eliot Handelman) (10/11/88)

In article <13733@iuvax.cs.indiana.edu> dfried@iuvax.cs.indiana.edu (Dan Friedman) writes:
>Are there any LISP implementations, especially of Common LISP,
>which get 5 instead of 1 as the result of the following run?

>>>> (defun eval (x) 1)

Good grief, what's the point of this beyond proving that your lisp actually
calls a function named eval which isn't coded online in your toplevel loop?
Please explain.

dyb@iuvax.cs.indiana.edu (10/12/88)

> Good grief, what's the point of this beyond proving that your lisp actually
> calls a function named eval which isn't coded online in your toplevel loop?
> Please explain.

I think Dan wants to know if he can reliably redefine eval so that his own
eval is used by the top-level read-eval-print loop.

R. Kent Dybvig                 | arpa: dyb@iuvax.cs.indiana.edu
Computer Science Department    | usenet: ...!ihnp4!iuvax!dyb
Indiana University             |         ...!pyramid!iuvax!dyb
Bloomington, IN 47405          | phone: 812/335-6486

barmar@think.COM (Barry Margolin) (10/13/88)

In article <20700006@iuvax> dyb@iuvax.cs.indiana.edu writes:
>I think Dan wants to know if he can reliably redefine eval so that his own
>eval is used by the top-level read-eval-print loop.

One of the proposals before X3J13 (the ANSI Common Lisp committee),
which I expect will be passed in a couple of months, specifies that
the effects of redefining any functions in the LISP package (i.e. any
function specified by the language standard) are undefined (it "is an
error", to use CLtL terminology).  So, I wouldn't write any code that
does this at the moment.

Barry Margolin
Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

jeff@aiva.ed.ac.uk (Jeff Dalton) (10/16/88)

In article <13733@iuvax.cs.indiana.edu> dfried@iuvax.cs.indiana.edu (Dan Friedman) writes:
>Are there any LISP implementations, especially of Common LISP,
>which get 5 instead of 1 as the result of the following run?
> (defun eval (x) 1); then 5 => 1

Yes, KCL.

>Does this change to eval ever change what load does?

No.

>Does (setf (symbol-function 'eval) #'(lambda (x) 1))
>do exactly the same thing as (defun eval (x) 1) in all 
>Common Lisp implementations?

Probably not.  DEFUN puts in a BLOCK, for one thing.  Also,
I dont' think there's anyhting that requires it to set the
function value exactly the same way SETF of SYMBOL-FUNCTION
does.

If you want to redefine EVAL and be sure it works, I think
you have to make a new package that shadows EVAL and LOAD,
redefines them, and (depending on how you want to do this)
exports all the other symbols the LISP package does.

-- Jeff

dharvey@wsccs.UUCP (David Harvey) (10/24/88)

In article <13733@iuvax.cs.indiana.edu>, dfried@iuvax.cs.indiana.edu (Dan Friedman) writes:
> Are there any LISP implementations, especially of Common LISP,
> which get 5 instead of 1 as the result of the following run?
> 
> >>> (defun eval (x) 1)
> eval
> 
> >>> 5
> 1
> 

	Yes, VAX' Common Lisp will return the value of 5.  It will
also not let you so cavalierly redefine this system primitive.  It
sqwawks about it in no uncertain terms before allowing you to hang
yourself.  5 returns 5, and (eval anyentity) returns 1.  If you do
an explicit eval of anthing over or less than 1 arg it will complain
now.

> Does this change to eval ever change what load does?
> 
> Does (setf (symbol-function 'eval) #'(lambda (x) 1))
> do exactly the same thing as (defun eval (x) 1) in all 
> Common Lisp implementations?
> 
> ... Dan

	Unfortunately, VAX Common Lisp will not sqwawk at you when you
redefine in this manner.  It accomplishes the same results as above.
Although I have not tried this with any other Common Lisp, the results
of the setf and the defun should be the same on all machines, since
the defun is nothing more than a macro that expands to the setf.  Oops,
check that.  This assumes that setf and defun are both found in package
Lisp.  Where else would they be?

dharvey		aliases:	Lispin' Dave
				Hacker Horribulus

I am responsible for Nobody,
and Nobody is responsible for me.
The only thing you can know for sure,
is that you can't know anything for sure.

aarons@cvaxa.sussex.ac.uk (Aaron Sloman) (11/14/88)

Catching up on netnews....

> From: dfried@iuvax.cs.indiana.edu (Dan Friedman)
> Message-ID: <13733@iuvax.cs.indiana.edu>
>Are there any LISP implementations, especially of Common LISP,
>which get 5 instead of 1 as the result of the following run?

>>>> (defun eval (x) 1)
>eval

>>>> 5
>1

In Poplog Common Lisp this produces an error.

Aaron Sloman,
School of Cognitive and Computing Sciences,
Univ of Sussex, Brighton, BN1 9QN, England