Re: package frenzy



Joris Bleys wrote:
Hi Pascal,

Don't I know you from somewhere? ;)

That must be a coincidence. ;)

Maybe you want (intern string :exporting-package) instead of read-line?

This might indeed be the function I'm looking for. It seems more elegant than setting *package* by hand. Oops, just read your reply :p, so I might look very stupid now :).

Maybe we both do. ;)

However, doing so requires the programmer to be realy careful when employing packages. I'd like to think that calling internal functions should automagically change the *package* to the package it was internal in, but I guess there are good reasons, which I don't yet fully (and might never :)) understand, for not doing so.

It's not that hard to understand. You have to get two things straight:

- When the Lisp reader reads in your source code (the original source code, not what you want to do at runtime), it uses *package* to determine the package of the symbols that are part of your source code. That's the sole purpose of *package*. You can reuse that functionality for your own stuff at runtime, but you have to imitate that behavior (so bind *package* correctly, or use INTERN with a second parameter appropriately). Read time and runtime are just two different times for a Lisp program, and you just have to keep them separated in your head.

- It might have been possible to automagically rebind *package*, whenever a function is called, to the home package of the symbol whose symbol-function is that function at runtime. This would incur a serious overhead though, and you would have to care about obvious and not so obvious corner cases. For example, what happens when you call an anonymous function? What if you change the fdefinition of a function at runtime? etc.


Pascal

--
2nd European Lisp and Scheme Workshop
July 26 - Glasgow, Scotland - co-located with ECOOP 2005
http://lisp-ecoop05.bknr.net/
.



Relevant Pages

  • modules vs. packages
    ... > module system of the underlying lisp. ... Common Lisp does have a trivial feature called modules. ... is that it has a unique name (with respect to its home package). ... the system version control and release and patching features. ...
    (comp.lang.lisp)
  • Re: Symbols - when are they garbage collected?
    ... home package is often considered to be interning it (certainly it is ... I agree that the CL function INTERN does not do this. ... string as its primary input, ... among Lisp practitioners. ...
    (comp.lang.lisp)
  • Re: Package: symbol reading woes
    ... The Lisp package system is not ... different from the problem with "wanting to load a package definition ...
    (comp.lang.lisp)
  • Re: Lisp newbie tips
    ... >>>From what I can tell most Lispers don't really use VIM, they use Emacs. ... > I read a lot about interactive Lisp debugging, ... > get the Debian cl-sdl package running with CMUCL. ...
    (comp.lang.lisp)
  • Re: Common Lisp and RegressionTesting
    ... And I did: from these posts, ... deleting the package in general or unbinding the symbol- ... I want to make it clear that I do not blame Lisp for how it works. ... Common Lisp is doing in the world). ...
    (comp.lang.lisp)