Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
package blues: load a file into a package
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mirko  
View profile  
 More options Dec 17 2008, 5:19 pm
Newsgroups: comp.lang.lisp
From: Mirko <Mirko.Vuko...@gmail.com>
Date: Wed, 17 Dec 2008 14:19:38 -0800 (PST)
Local: Wed, Dec 17 2008 5:19 pm
Subject: package blues: load a file into a package
Here is the story:

I have a package A.  I would like to load a file B.lisp that has no
package definitions.  However when (in-package :A), B's symbols are
invisible.  They are in :cl-user.

I tried putting (load #P/"/path-to-B/B") inside A.lisp thinking (I
mean hoping) that this would include B's symbols into package A, but
that did not work.

I could define a package B, export its symbols and import them into A,
but it is an overkill for the small file B.  In addition, B is a
source file generated by Andrew Smith (state machine), and I don't
want to change it.

I could keep A without its package (keep it in cl-user), but it
depends on other packages, and I do not know how to import the
`public' symbols from those other packages into cl-user.

Any other options?

Thank you,

Mirko


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tamas K Papp  
View profile  
 More options Dec 17 2008, 5:25 pm
Newsgroups: comp.lang.lisp
From: Tamas K Papp <tkp...@gmail.com>
Date: 17 Dec 2008 22:25:48 GMT
Local: Wed, Dec 17 2008 5:25 pm
Subject: Re: package blues: load a file into a package

On Wed, 17 Dec 2008 14:19:38 -0800, Mirko wrote:
> I tried putting (load #P/"/path-to-B/B") inside A.lisp thinking (I mean
> hoping) that this would include B's symbols into package A, but that did
> not work.

But I think it should, unless you do something to *package* inside B.lisp.

> Any other options?

You could put an (in-package :a) inside B.lisp.

Tamas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Joswig  
View profile  
 More options Dec 17 2008, 5:44 pm
Newsgroups: comp.lang.lisp
From: Rainer Joswig <jos...@lisp.de>
Date: Wed, 17 Dec 2008 23:44:19 +0100
Local: Wed, Dec 17 2008 5:44 pm
Subject: Re: package blues: load a file into a package
In article
<b33781f8-05a2-4f1c-85f2-3f4c9a640...@e24g2000vbe.googlegroups.com>,

 Mirko <Mirko.Vuko...@gmail.com> wrote:
> Here is the story:

> I have a package A.  I would like to load a file B.lisp that has no
> package definitions.  However when (in-package :A), B's symbols are
> invisible.  They are in :cl-user.

If they are in CL-USER, then *package* really is CL-USER
when you load that package.

> I tried putting (load #P/"/path-to-B/B") inside A.lisp thinking (I
> mean hoping) that this would include B's symbols into package A, but
> that did not work.

What exactly did you do? When compile file a and it
has a load statement, nothing happens.
You have to tell the compiler that it should load
it (using EVAL-WHEN).

Anyway a simple example with load:

RJMBP:tmp joswig$ cat a.lisp
(defpackage "A" (:use "CL"))

(in-package "A")

(load "b.lisp")

(b)

RJMBP:tmp joswig$ cat b.lisp
(defun b ()
  (print 'hi-there))

RJMBP:tmp joswig$ cmucl

* (load "a.lisp")

; Loading #P"/private/tmp/a.lisp".
;; Loading #P"/private/tmp/b.lisp".

HI-THERE
T
*

> I could define a package B, export its symbols and import them into A,
> but it is an overkill for the small file B.  In addition, B is a
> source file generated by Andrew Smith (state machine), and I don't
> want to change it.

> I could keep A without its package (keep it in cl-user), but it
> depends on other packages, and I do not know how to import the
> `public' symbols from those other packages into cl-user.

> Any other options?

> Thank you,

> Mirko

--
http://lispm.dyndns.org/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
budden  
View profile  
 More options Dec 17 2008, 5:56 pm
Newsgroups: comp.lang.lisp
From: budden <budden-l...@mail.ru>
Date: Wed, 17 Dec 2008 14:56:23 -0800 (PST)
Local: Wed, Dec 17 2008 5:56 pm
Subject: Re: package blues: load a file into a package
Yeah, the best solution is to put (in-package :a) to b.lisp. Yes, I
know you can't. Really?
1. You can read Andrew Smith manual. If it is a good tool, it should
be able to issue defpackage form. Maybe some
configuration option help.
2. If not, you might patch codegenerator itself.
3. If not, just make new file b.tmp.lisp from b.lisp, where (in-
package :a) is prepended to b.lisp contents
and load b.tmp.lisp instead.
4. After all, you can define your own version of load.
Simplest thing is like this:

(defun my-load (file-name) (let ((*package* (find-package :iterate)))
  (with-open-file (in file-name)
     (loop for s = (read in nil nil)
           unless s do (loop-finish)
           do (eval s)))))

Note you lose ability to compile here. If you want better solution,
set up slime, sbcl/ccl and navigate through implementation sources -
you'll be able to borrow code from there.

--------------------------------------------------------------
Budden, $5/hour lisp freelancer. Hire me until it is too
late


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Dec 18 2008, 2:58 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <tfb+goo...@tfeb.org>
Date: Wed, 17 Dec 2008 23:58:57 -0800 (PST)
Local: Thurs, Dec 18 2008 2:58 am
Subject: Re: package blues: load a file into a package
On Dec 17, 10:19 pm, Mirko <Mirko.Vuko...@gmail.com> wrote:

> I tried putting (load #P/"/path-to-B/B") inside A.lisp thinking (I
> mean hoping) that this would include B's symbols into package A, but
> that did not work.

Bind *PACKAGE* to the right package before doing this.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
budden  
View profile  
 More options Dec 18 2008, 3:47 am
Newsgroups: comp.lang.lisp
From: budden <budden-l...@mail.ru>
Date: Thu, 18 Dec 2008 00:47:38 -0800 (PST)
Local: Thurs, Dec 18 2008 3:47 am
Subject: Re: package blues: load a file into a package
> Bind *PACKAGE* to the right package before doing this.

O-oo-ps. I was wrong :)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mirko  
View profile  
 More options Dec 18 2008, 12:20 pm
Newsgroups: comp.lang.lisp
From: Mirko <Mirko.Vuko...@gmail.com>
Date: Thu, 18 Dec 2008 09:20:34 -0800 (PST)
Local: Thurs, Dec 18 2008 12:20 pm
Subject: Re: package blues: load a file into a package
On Dec 17, 5:19 pm, Mirko <Mirko.Vuko...@gmail.com> wrote:

I tried Rainer's simple example and it does work.  The loaded file is
in the package of the parent (hyperspec says the same thing).

But in my case I am still having trouble.  Evidently my problem lies
somewhere else.  For now, I did the `dirty' thing, and inserted a (in-
package ...) statement in the loaded file.

I will try to dig into the issue later.

Thanks to all the replied,

Mirko


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
budden  
View profile  
 More options Dec 18 2008, 5:49 pm
Newsgroups: comp.lang.lisp
From: budden <budden-l...@mail.ru>
Date: Thu, 18 Dec 2008 14:49:26 -0800 (PST)
Local: Thurs, Dec 18 2008 5:49 pm
Subject: Re: package blues: load a file into a package
You might also try
(let ((*package* (find-package :a)))
  (load "b"))
This is how I understand Tim Bradshaw's recommendation.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »