Re: package frenzy
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Mon, 30 May 2005 16:51:39 +0200
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/ .
- References:
- Re: package frenzy
- From: Pascal Costanza
- Re: package frenzy
- From: Joris Bleys
- Re: package frenzy
- Prev by Date: Re: package frenzy
- Next by Date: Re: Critique my (a newbie's) debugging macro
- Previous by thread: Re: package frenzy
- Next by thread: Re: package frenzy
- Index(es):
Relevant Pages
|
|