Re: Woohoo! My macros are now (semi) hygienic
- From: Ron Garret <rNOSPAMon@xxxxxxxxxxx>
- Date: Sat, 23 Feb 2008 08:50:23 -0800
In article
<31ee5725-d999-4306-9ce0-114e2e3faa6c@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"Leslie P. Polzer" <leslie.polzer@xxxxxxx> wrote:
I'm very interested in this stuff. I don't have time for checking it
out
right now, though. What will we get when you officially release it?
I'm shooting for Monday. It's mostly a matter of writing a primer, and
deleting some old code that doesn't work any more. And testing.
Could you make up a quick comparison of what package problems it will
solve?
There are two main problems (or maybe I should call them annoyances)
with packages that Lexicons were designed to solve:
1. The need to manually build and maintain exported symbol lists
2. The fact that the reader causes side-effects which, if packages have
not been properly set up, can be difficult to undo. For example, if you
load some code that relies on a package before that package has been
used then you end up with interned symbols in the using package that now
must all be uninterned before the package can be used.
I'm actually particularly proud of the solution to problem #2 because
lexicons can "defer" lexical bindings, e.g.:
? (in-lexicon "LIBRARY")
#<lexicon LIBRARY>
? (ldefun library-function () 'library)
LIBRARY-FUNCTION
? (in-lexicon "MYLEX")
#<lexicon MYLEX>
? (ldefun my-fn () (library-function))
; Warning: Defering lexical binding of LIBRARY-FUNCTION
; While executing: *REF, in process Listener(117).
MY-FN
; Oops, forgot to import the library
? (use-lexicon "LIBRARY")
(#<lexicon LIBRARY> #<lexicon JACK> #<lexicon BOB>)
? (my-fn)
Resolving lexical binding of LIBRARY-FUNCTION
LIBRARY
?
So for this common class of error, not only do you not have to clean up
your package, but most of the time you don't even have to recompile your
code.
Contrast that with the package situation:
? (in-package "LIBRARY")
#<Package "LIBRARY">
? (defun pkg-library-function () 'pkg-library-function)
PKG-LIBRARY-FUNCTION
? (export 'pkg-library-function)
T
? (in-package :cl-user)
#<Package "COMMON-LISP-USER">
? (defun pkg-my-fn () (pkg-library-function))
;Compiler warnings :
; Undefined function PKG-LIBRARY-FUNCTION, in PKG-MY-FN.
PKG-MY-FN
? (use-package "LIBRARY")
Error: Using #<Package "LIBRARY"> in #<Package "COMMON-LISP-USER">1>
would cause name conflicts with symbols already present in that package:
PKG-LIBRARY-FUNCTION LIBRARY:PKG-LIBRARY-FUNCTION
LIBRARY-FUNCTION LIBRARY:LIBRARY-FUNCTION
While executing: CCL::USE-PACKAGE-1, in process Listener(117).
Type :GO to continue, :POP to abort, :R for a list of available restarts.
If continued: Try again to use #<Package "LIBRARY"> in #<Package "COMMON-LISP-USER">
Type :? for other options.
This is not that hard to recover from once you know what you're doing,
but it can be quite vexing for newcomers.
rg
.
- Follow-Ups:
- Re: Woohoo! My macros are now (semi) hygienic
- From: Kaz Kylheku
- Re: Woohoo! My macros are now (semi) hygienic
- From: Leslie P. Polzer
- Re: Woohoo! My macros are now (semi) hygienic
- References:
- Woohoo! My macros are now (semi) hygienic
- From: Ron Garret
- Re: Woohoo! My macros are now (semi) hygienic
- From: Kaz Kylheku
- Re: Woohoo! My macros are now (semi) hygienic
- From: Kent M Pitman
- Re: Woohoo! My macros are now (semi) hygienic
- From: Ron Garret
- Re: Woohoo! My macros are now (semi) hygienic
- From: Kent M Pitman
- Re: Woohoo! My macros are now (semi) hygienic
- From: Ron Garret
- Re: Woohoo! My macros are now (semi) hygienic
- From: Leslie P. Polzer
- Woohoo! My macros are now (semi) hygienic
- Prev by Date: Re: Bundling elements of a list
- Next by Date: Re: What's up with Scheme macros?
- Previous by thread: Re: Woohoo! My macros are now (semi) hygienic
- Next by thread: Re: Woohoo! My macros are now (semi) hygienic
- Index(es):
Relevant Pages
|