From: Greg Buchholz
Subject: Special forms vs. Lexical scope vs. Packages vs. ...
Date: 
Message-ID: <1169234825.404483.233360@38g2000cwa.googlegroups.com>
    The following code must probe some undefined part of the CL spec,
since four different implementations give four different answers...

(make-package 'foo)
(in-package foo)

(cl::flet ((if (x) x))
  (cl::if cl::t (cl::print "t") (cl::print "Wha?"))
  (cl::print (if 4)))

...In SBCL 1.0, everything works without any errors.

Clisp 2.41:  "*** - EVAL/APPLY: too many arguments given to IF"

CMUCL Snapshot 2005-03:  "; Error: Special form is an illegal function
name: IF."

In GCL 2.6.5:  "Error in CONDITIONS::CLCS-LOAD [or a callee]: The
variable FOO is unbound."

So which egregious errors are lurking in that snippet?

Thanks,

Greg Buchholz

From: Zach Beane
Subject: Re: Special forms vs. Lexical scope vs. Packages vs. ...
Date: 
Message-ID: <m3bqkuu7qw.fsf@unnamed.xach.com>
"Greg Buchholz" <················@yahoo.com> writes:

>     The following code must probe some undefined part of the CL spec,
> since four different implementations give four different answers...
> 
> (make-package 'foo)

If you don't supply a :USE argument to MAKE-PACKAGE, the
implementation will supply you with one. Many include the CL package
in that default list, but you can't rely on it (SBCL's list is empty,
for example). If you want cross-lisp predictability, you must provide
a USE list explicitly.

> (in-package foo)
> 
> (cl::flet ((if (x) x))
>   (cl::if cl::t (cl::print "t") (cl::print "Wha?"))
>   (cl::print (if 4)))
> 
> ...In SBCL 1.0, everything works without any errors.

That's because SBCL doesn't use CL by default. Here's what happens you
explicitly use it:

   Compile-time error:
     Special form is an illegal function name: IF

> So which egregious errors are lurking in that snippet?

Missing USE list.

Zach
From: Pascal Bourguignon
Subject: Re: Special forms vs. Lexical scope vs. Packages vs. ...
Date: 
Message-ID: <87hcumu7go.fsf@thalassa.informatimago.com>
"Greg Buchholz" <················@yahoo.com> writes:

>     The following code must probe some undefined part of the CL spec,
> since four different implementations give four different answers...
>
> (make-package 'foo)
> (in-package foo)
>
> (cl::flet ((if (x) x))
>   (cl::if cl::t (cl::print "t") (cl::print "Wha?"))
>   (cl::print (if 4)))
>
> ...In SBCL 1.0, everything works without any errors.
>
> Clisp 2.41:  "*** - EVAL/APPLY: too many arguments given to IF"
>
> CMUCL Snapshot 2005-03:  "; Error: Special form is an illegal function
> name: IF."
>
> In GCL 2.6.5:  "Error in CONDITIONS::CLCS-LOAD [or a callee]: The
> variable FOO is unbound."
>
> So which egregious errors are lurking in that snippet?

MAKE-PACKAGE takes a keyword argument use list. If you don't give it,
the default value is implementation dependant (same with DEFPACKAGE).

Therefore in the package foo, you can have already interned any kind
of symbols, including cl::if, and you may, or may not, 
have (eq 'cl::if 'if).


It might be easier to use shadow:

(shadow 'if)

(flet ((if (x) x))
  (cl:if t (print "t") (print "what?"))
  (print (if 4)))

Or, if you need an empty package, give an empty use list.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

READ THIS BEFORE OPENING PACKAGE: According to certain suggested
versions of the Grand Unified Theory, the primary particles
constituting this product may decay to nothingness within the next
four hundred million years.
From: Greg Buchholz
Subject: Re: Special forms vs. Lexical scope vs. Packages vs. ...
Date: 
Message-ID: <1169242064.103922.295470@38g2000cwa.googlegroups.com>
Zach Beane wrote:
> If you don't supply a :USE argument to MAKE-PACKAGE, the
> implementation will supply you with one.

Pascal Bourguignon wrote:
> MAKE-PACKAGE takes a keyword argument use list. If you don't give it,
> the default value is implementation dependant (same with DEFPACKAGE).

    Ah, that's it.

Thanks,

Greg Buchholz