From: Jonathan BAILLEUL
Subject: Newbie question: PACKAGES
Date: 
Message-ID: <38C7BB0B.C4092A41@emi.u-bordeaux.fr>
Hello.

I know my request may upset some of the most experienced lisp
programmers, but I really tried to answer it on my own and I still can't
find out the solution.

I have two files: one containing and defining a package, and the other
attempting to access the package exported functions.
I am using cmu-cl and unfortunately I cannot access the exported
functions without using ::.
Where did I failed?

/////////////////////////////////////////////////////
//File PACK1.lisp
(defpackage "GLOS-PACK1"
  (:use "COMMON-LISP")
  (:export "my-inc")
  (:nicknames "GLOS")
  (:documentation "le pack 1 de glos"))
  
(in-package glos-pack1)

;;exported (so) public function
(defun my-inc (x)
  (+ 1 x))

;;non exported private function
(defun my-inc2 (x)
  (+ 2 x))

;;in last resort 
;;(export 'my-inc)

/////////////////////////////////////////////////////
//File TOP.lisp
;;loading the file and then glos-pack1 definition
(load "PACK1.lisp")

;;in order to access directly exported symbols from glos-pack1
(use-package 'glos-pack1)

;;logically we should use my-inc directly
(my-inc 6)
;;unfortunately CMU-CL says this function is undefined

;;trying with one colon (what does it mean?)
(glos:my-inc 5)
;;unfortunately CMU-CL says this function is undefined

;;brutal access to the function, violating package rights 
(glos::my-inc 5)
;;works with any function in the package



When i add (export "my-inc") in pack1.lisp, it works at last. but where
is the point of exporting that function in the defpackage call, so?
Thanks for any suggestion. 


-- 
----------------------------------------------
Jonathan BAILLEUL (········@emi.u-bordeaux.fr)
Maitrise Informatique, Universite Bordeaux I

From: Tunc Simsek
Subject: Re: Newbie question: PACKAGES
Date: 
Message-ID: <Pine.SOL.4.10.10003090723590.23061-100000@tudor.EECS.Berkeley.EDU>
Try

  (:export "MY-INC")

rather than

  (:export "my-inc")

Good luck,
Tunc

On Thu, 9 Mar 2000, Jonathan BAILLEUL wrote:

> Hello.
> 
> I know my request may upset some of the most experienced lisp
> programmers, but I really tried to answer it on my own and I still can't
> find out the solution.
> 
> I have two files: one containing and defining a package, and the other
> attempting to access the package exported functions.
> I am using cmu-cl and unfortunately I cannot access the exported
> functions without using ::.
> Where did I failed?
> 
> /////////////////////////////////////////////////////
> //File PACK1.lisp
> (defpackage "GLOS-PACK1"
>   (:use "COMMON-LISP")
>   (:export "my-inc")
>   (:nicknames "GLOS")
>   (:documentation "le pack 1 de glos"))
>   
> (in-package glos-pack1)
> 
> ;;exported (so) public function
> (defun my-inc (x)
>   (+ 1 x))
> 
> ;;non exported private function
> (defun my-inc2 (x)
>   (+ 2 x))
> 
> ;;in last resort 
> ;;(export 'my-inc)
> 
> /////////////////////////////////////////////////////
> //File TOP.lisp
> ;;loading the file and then glos-pack1 definition
> (load "PACK1.lisp")
> 
> ;;in order to access directly exported symbols from glos-pack1
> (use-package 'glos-pack1)
> 
> ;;logically we should use my-inc directly
> (my-inc 6)
> ;;unfortunately CMU-CL says this function is undefined
> 
> ;;trying with one colon (what does it mean?)
> (glos:my-inc 5)
> ;;unfortunately CMU-CL says this function is undefined
> 
> ;;brutal access to the function, violating package rights 
> (glos::my-inc 5)
> ;;works with any function in the package
> 
> 
> 
> When i add (export "my-inc") in pack1.lisp, it works at last. but where
> is the point of exporting that function in the defpackage call, so?
> Thanks for any suggestion. 
> 
> 
> -- 
> ----------------------------------------------
> Jonathan BAILLEUL (········@emi.u-bordeaux.fr)
> Maitrise Informatique, Universite Bordeaux I
> 
> 
From: Tim Bradshaw
Subject: Re: Newbie question: PACKAGES
Date: 
Message-ID: <ey37lfc6s9t.fsf@cley.com>
* Tunc Simsek wrote:
>   (:export "MY-INC")

> rather than

>   (:export "my-inc")

In the context of the case-sensitivity thread, it's better perhaps to
say (:export #:my-inc)

--tim
From: Fred Gilham
Subject: Re: Newbie question: PACKAGES
Date: 
Message-ID: <u7n1o83vlo.fsf@snapdragon.csl.sri.com>
Tunc Simsek <······@tudor.EECS.Berkeley.EDU> writes:

> Try
> 
>   (:export "MY-INC")
> 
> rather than
> 
>   (:export "my-inc")
> 

Or just

 (:export my-inc)


-- 
Fred Gilham                                      ······@csl.sri.com
I have over the years been viewed as a man of the left and a man of
the right, and the truth is that I've never put much stake in such
labels. But this I have learned: the left patrols its borders and
checks membership credentials ever so much more scrupulously, even
ruthlessly, than does the right.            -- Richard John Neuhaus
From: Michael Kappert
Subject: Re: Newbie question: PACKAGES
Date: 
Message-ID: <38C8AF3D.94E2A0E7@iitb.fhg.de>
Fred Gilham wrote:
> 
> Tunc Simsek <······@tudor.EECS.Berkeley.EDU> writes:
> 
> > Try
> >
> >   (:export "MY-INC")
> >
> > rather than
> >
> >   (:export "my-inc")
> >
> 
> Or just
> 
>  (:export my-inc)

No, this will intern my-inc in the current package (call it P).
You won't be able to "use-package" the newly defined package in P.


Michael

-- 
Michael Kappert
Fraunhofer IITB
Fraunhoferstr. 1                                       Phone: +49(0)721/6091-477
D-76131 Karlsruhe, Germany                             EMail: ···@iitb.fhg.de
From: Jonathan BAILLEUL
Subject: Re: Newbie question: PACKAGES
Date: 
Message-ID: <38C8FC47.C709B20D@emi.u-bordeaux.fr>
Tunc Simsek wrote:
> 
> Try
> 
>   (:export "MY-INC")
> 
> rather than
> 
>   (:export "my-inc")
> 
> Good luck,
> Tunc
> 
> On Thu, 9 Mar 2000, Jonathan BAILLEUL wrote:
> 
> > Hello.
> >
> > I know my request may upset some of the most experienced lisp
> > programmers, but I really tried to answer it on my own and I still can't
> > find out the solution.
> >
> > I have two files: one containing and defining a package, and the other
> > attempting to access the package exported functions.
> > I am using cmu-cl and unfortunately I cannot access the exported
> > functions without using ::.
> > Where did I failed?
> >
> > /////////////////////////////////////////////////////
> > //File PACK1.lisp
> > (defpackage "GLOS-PACK1"
> >   (:use "COMMON-LISP")
> >   (:export "my-inc")
> >   (:nicknames "GLOS")
> >   (:documentation "le pack 1 de glos"))
> >
> > (in-package glos-pack1)
> >
> > ;;exported (so) public function
> > (defun my-inc (x)
> >   (+ 1 x))
> >
> > ;;non exported private function
> > (defun my-inc2 (x)
> >   (+ 2 x))
> >
> > ;;in last resort
> > ;;(export 'my-inc)
> >
> > /////////////////////////////////////////////////////
> > //File TOP.lisp
> > ;;loading the file and then glos-pack1 definition
> > (load "PACK1.lisp")
> >
> > ;;in order to access directly exported symbols from glos-pack1
> > (use-package 'glos-pack1)
> >
> > ;;logically we should use my-inc directly
> > (my-inc 6)
> > ;;unfortunately CMU-CL says this function is undefined
> >
> > ;;trying with one colon (what does it mean?)
> > (glos:my-inc 5)
> > ;;unfortunately CMU-CL says this function is undefined
> >
> > ;;brutal access to the function, violating package rights
> > (glos::my-inc 5)
> > ;;works with any function in the package
> >
> >
> >
> > When i add (export "my-inc") in pack1.lisp, it works at last. but where
> > is the point of exporting that function in the defpackage call, so?
> > Thanks for any suggestion.
> >
> >
> > --
> > ----------------------------------------------
> > Jonathan BAILLEUL (········@emi.u-bordeaux.fr)
> > Maitrise Informatique, Universite Bordeaux I
> >
> >

Ok, this works fine!
Thank you..

In fact, I have in mind the relationship model of C/C++.
I would like to know if we should access "visible" elements of a package
using "nick:symbol" or "symbol"?
What is the convention? (in my example, both are working).


-- 
----------------------------------------------
Jonathan BAILLEUL (········@emi.u-bordeaux.fr)
Maitrise Informatique, Universite Bordeaux I