Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why is in-package a macro?

5 views
Skip to first unread message

Peter Seibel

unread,
Oct 27, 2002, 7:42:24 PM10/27/02
to
If all it does (per the HyperSpec) is set *package*, couldn't that be
done via a function? Or is it someting about the other sentence in the
"Side Effects" section:

If the in-package form is a top level form, this assignment also
occurs at compile time.

that means it has to be a macro? Just a guess--I'm hoping that when I
understand why it's a macro I'll have increased either my
understanding of macros or of Lisp history.

-Peter

--
Peter Seibel
pe...@javamonkey.com

Erik Naggum

unread,
Oct 27, 2002, 7:57:32 PM10/27/02
to
* Peter Seibel

| Just a guess--I'm hoping that when I understand why it's a macro I'll
| have increased either my understanding of macros or of Lisp history.

It used to be an operator that the evaluator/loader/etc had to recognize
specially. It is better to let `eval-when´ be that operator and make
`in-package´ be a macro that expands to use it.

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.

Peter Seibel

unread,
Oct 28, 2002, 12:47:14 AM10/28/02
to
Erik Naggum <er...@naggum.no> writes:

> * Peter Seibel
> | Just a guess--I'm hoping that when I understand why it's a macro I'll
> | have increased either my understanding of macros or of Lisp history.
>
> It used to be an operator that the evaluator/loader/etc had to recognize
> specially. It is better to let `eval-when´ be that operator and make
> `in-package´ be a macro that expands to use it.

I suspected that it had something to do with 'eval-when'. Duh--if I
had thought to macroexpand '(in-package "FOO") I would have known it.
Now to go wrap my head around 'eval-when'. Thanks.

Erik Naggum

unread,
Oct 28, 2002, 10:22:45 AM10/28/02
to
* Peter Seibel <pe...@javamonkey.com>

| Now to go wrap my head around 'eval-when'. Thanks.

You may find that `eval-when´ is quite counter-intuitive until you have
built up your intutions correctly. This is a known hard issue because
the different times that things are evaluated in Common Lisp is amenable
to grave mistakes in one's understanding without debilitating effects on
one's ability to use the system well. In the absence of correctors, many
people have gone very wrong and believed very wrong things for very long
before they had to revise it drastically in order to fully understand
`eval-when´. Be prepared to be surprised, and it should be a lot easier.

Vassil Nikolov

unread,
Oct 29, 2002, 4:03:08 AM10/29/02
to
On Mon, 28 Oct 2002 05:47:14 GMT, Peter Seibel <pe...@javamonkey.com> said:

[...]
PS> Now to go wrap my head around 'eval-when'.

http://www.eskimo.com/~van/lib/lisp/describe-eval-when.lisp
is something I wrote about four years ago to help me figure out what
happens in various EVAL-WHEN forms. It might be useful.

---Vassil.

--
For an M-person job assigned to an N-person team, only rarely M=N.

Peter Seibel

unread,
Oct 30, 2002, 2:23:00 AM10/30/02
to
Vassil Nikolov <vnik...@poboxes.com> writes:

> On Mon, 28 Oct 2002 05:47:14 GMT, Peter Seibel <pe...@javamonkey.com> said:
>
> [...]
> PS> Now to go wrap my head around 'eval-when'.
>
> http://www.eskimo.com/~van/lib/lisp/describe-eval-when.lisp
> is something I wrote about four years ago to help me figure out what
> happens in various EVAL-WHEN forms. It might be useful.

Thanks. I'll check it out.

0 new messages