From: Paolo Amoroso
Subject: Returning symbols while defining packages
Date: 
Message-ID: <3769b4b7.60870@news.mclink.it>
The code of lisp2wish by Matthias Lindner (for controlling a wish--the Tcl
shell with Tk--session from Common Lisp), written in 1995, contains an
idiom that can be summarized like this:

;;; Beginning of file

(in-package "USER")

#-:KCL
(defpackage APP-NAME
  (:use LISP #+:VENDOR-A PKG-VA #+:VENDOR-B PKG-VB)
  (:shadowing-import-from USER TEST-APP)
  (:export "SYMBOL-1"
           ;; ... more symbols
           "SYMBOL-n"))

#+:KCL
(eval-when (load eval compile)
  (unless (find-package "APP-NAME")
    'TEST-APP                             ; [*]
    (make-package "APP-NAME")
    (in-package "APP-NAME")
    (shadowing-import '(USER::TEST-APP))  ; [+]
    (export (mapcar #'intern '("SYMBOL-1"
                               ;; ... more symbols
                               "SYMBOL-n")))))

(in-package "APP-NAME")

;;; Definitions of variables, functions and macros corresponding
;;; to SYMBOL-1 ... SYMBOL-n

;;; End of file

TEST-APP is a function that runs a demo of the application. This code takes
into account CLtL1 (#+:KCL) and post-CLtL1 (#-:KCL) package
semantics--right? But I don't understand why the symbol TEST-APP is
returned (am I using the right term in this context?) by the line marked
with [*] above. Isn't it thrown away? The only explanation I can think of
is that the code, while still in package USER, returns TEST-APP so that it
gets interned and can later be referenced by SHADOWING-IMPORT in line [+].


Paolo
-- 
Paolo Amoroso <·······@mclink.it>

From: Stig Hemmer
Subject: Re: Returning symbols while defining packages
Date: 
Message-ID: <ekvg13rnkr8.fsf@gnoll.pvv.ntnu.no>
·······@mclink.it (Paolo Amoroso) writes:
> #+:KCL
> (eval-when (load eval compile)
>   (unless (find-package "APP-NAME")
>     'TEST-APP                             ; [*]
>     (make-package "APP-NAME")
>     (in-package "APP-NAME")
>     (shadowing-import '(USER::TEST-APP))  ; [+]
>     (export (mapcar #'intern '("SYMBOL-1"
>                                ;; ... more symbols
>                                "SYMBOL-n")))))
> 
> (in-package "APP-NAME")

The symbol TEST-APP is created when this code passes READ. At this
time, *PACKAGE* points at the USER package.  At evaluation time the
symbol has no effect but then it doesn't matter.

However, I fail to see why one couldn't simply
    (shadowing-import 'TEST-APP)   ; [+]
since that should give the same effect.  There is an IN-PACKAGE form
before that, but READ should handle the entire EVAL-WHEN form and
intern everything before the IN-PACKAGE takes effect. (Or ?)

Stig Hemmer,
Jack of a Few Trades.
From: Marco Antoniotti
Subject: Re: Returning symbols while defining packages
Date: 
Message-ID: <lwu2s6hh5j.fsf@copernico.parades.rm.cnr.it>
·······@mclink.it (Paolo Amoroso) writes:

> The code of lisp2wish by Matthias Lindner (for controlling a wish--the Tcl
> shell with Tk--session from Common Lisp), written in 1995, contains an
> idiom that can be summarized like this:
> 
> ;;; Beginning of file
> 
> (in-package "USER")
> 
> #-:KCL
> (defpackage APP-NAME
>   (:use LISP #+:VENDOR-A PKG-VA #+:VENDOR-B PKG-VB)
>   (:shadowing-import-from USER TEST-APP)
>   (:export "SYMBOL-1"
>            ;; ... more symbols
>            "SYMBOL-n"))
> 
> #+:KCL
> (eval-when (load eval compile)
>   (unless (find-package "APP-NAME")
>     'TEST-APP                             ; [*]
>     (make-package "APP-NAME")
>     (in-package "APP-NAME")
>     (shadowing-import '(USER::TEST-APP))  ; [+]
>     (export (mapcar #'intern '("SYMBOL-1"
>                                ;; ... more symbols
>                                "SYMBOL-n")))))
> 
> (in-package "APP-NAME")
> 
> ;;; Definitions of variables, functions and macros corresponding
> ;;; to SYMBOL-1 ... SYMBOL-n
> 
> ;;; End of file
> 
> TEST-APP is a function that runs a demo of the application. This code takes
> into account CLtL1 (#+:KCL) and post-CLtL1 (#-:KCL) package
> semantics--right? But I don't understand why the symbol TEST-APP is
> returned (am I using the right term in this context?) by the line marked
> with [*] above. Isn't it thrown away? The only explanation I can think of
> is that the code, while still in package USER, returns TEST-APP so that it
> gets interned and can later be referenced by SHADOWING-IMPORT in line [+].
> 
> 

#+personal-gripe-ahead

The correct solution to your problem (the one adopted by ILISP) is the
following 

#+(or :gcl :akcl :ibcl :kcl)
(eval-when (load compile eval)
  (unless (fboundp 'defpackage)
     (error "You are using a Common Lisp which does not define DEFPACKAGE.~
             (Most likely a KCL derivative like GCL).~
             Please load a DEFPACKAGE definition in your system before~
             attempting to compile ZZZ.")))


Of course it may be that the latest GCL has seen the ligth. I don't
really know and I want to be proven wrong.
Meanwhile, ILISP will contain a warning of the kind above.

Cheers

-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa
From: Paolo Amoroso
Subject: Re: Returning symbols while defining packages
Date: 
Message-ID: <37715101.3158872@news.mclink.it>
On 17 Jun 1999 19:27:04 +0200, Marco Antoniotti
<·······@copernico.parades.rm.cnr.it> wrote:

> The correct solution to your problem (the one adopted by ILISP) is the
> following 
[...]
>      (error "You are using a Common Lisp which does not define DEFPACKAGE.~
>              (Most likely a KCL derivative like GCL).~
>              Please load a DEFPACKAGE definition in your system before~
>              attempting to compile ZZZ.")))
[...]
> Of course it may be that the latest GCL has seen the ligth. I don't
> really know and I want to be proven wrong.
> Meanwhile, ILISP will contain a warning of the kind above.

My posting to comp.lang.lisp (Subject: Returning symbols while defining
packages) is completely unrelated to the package problem (Subject:
Incorrect package inference) I reported to the ILISP mailing list. I just
happened to post the two messages more or less at the same time. I have
been curious about the former topic for a few months, but I installed ILISP
just a few days ago and run across the problem while playing with it.

I never used neither GCL nor any of its ancestors or derivatives. I have
the latest versions of ACL, CLISP and CMUCL.


Paolo

P.S.
By the way, lisp2wish works fine with CLISP, the only one with which I
tested it.
-- 
Paolo Amoroso <·······@mclink.it>
From: Marco Antoniotti
Subject: Re: Returning symbols while defining packages
Date: 
Message-ID: <lwbteey1f3.fsf@copernico.parades.rm.cnr.it>
·······@mclink.it (Paolo Amoroso) writes:

> On 17 Jun 1999 19:27:04 +0200, Marco Antoniotti
> <·······@copernico.parades.rm.cnr.it> wrote:
> 
> > The correct solution to your problem (the one adopted by ILISP) is the
> > following 
> [...]
> >      (error "You are using a Common Lisp which does not define DEFPACKAGE.~
> >              (Most likely a KCL derivative like GCL).~
> >              Please load a DEFPACKAGE definition in your system before~
> >              attempting to compile ZZZ.")))
> [...]
> > Of course it may be that the latest GCL has seen the ligth. I don't
> > really know and I want to be proven wrong.
> > Meanwhile, ILISP will contain a warning of the kind above.
> 
> My posting to comp.lang.lisp (Subject: Returning symbols while defining
> packages) is completely unrelated to the package problem (Subject:
> Incorrect package inference) I reported to the ILISP mailing list. I just
> happened to post the two messages more or less at the same time. I have
> been curious about the former topic for a few months, but I installed ILISP
> just a few days ago and run across the problem while playing with it.
> 
> I never used neither GCL nor any of its ancestors or derivatives. I have
> the latest versions of ACL, CLISP and CMUCL.
> 
> 
> Paolo
> 
> P.S.
> By the way, lisp2wish works fine with CLISP, the only one with which I
> tested it.

Sorry, I should have read your post more carefully.  Anyway, any time
I see these A?[KG]CL related posts concerning DEFPACKAGE I get really
upset.

Cheers


-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa
From: Raymond Toy
Subject: Re: Returning symbols while defining packages
Date: 
Message-ID: <m31zf8re0m.fsf@lorien.users.mindspring.com>
>>>>> "Marco" == Marco Antoniotti <·······@copernico.parades.rm.cnr.it> writes:

    Marco> Of course it may be that the latest GCL has seen the
    Marco> ligth. I don't really know and I want to be proven wrong.

I don't think GCL has yet seen the light.  However, the CMU Lisp
archives has a defpackage that works with GCL.  You can also get a
copy from http://www.mindspring.com/~rtoy/software.

Ray
From: Marco Antoniotti
Subject: Re: Returning symbols while defining packages
Date: 
Message-ID: <lw674jhglt.fsf@copernico.parades.rm.cnr.it>
Raymond Toy <····@mindspring.com> writes:

> >>>>> "Marco" == Marco Antoniotti <·······@copernico.parades.rm.cnr.it> writes:
> 
>     Marco> Of course it may be that the latest GCL has seen the
>     Marco> ligth. I don't really know and I want to be proven wrong.
> 
> I don't think GCL has yet seen the light.  However, the CMU Lisp
> archives has a defpackage that works with GCL.  You can also get a
> copy from http://www.mindspring.com/~rtoy/software.
> 

Exactly my point. 

Cheers

-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa