From: Rupert Swarbrick
Subject: AIF and scoping problem (I think)
Date: 
Message-ID: <DOqdnU1hUMfsQ3HanZ2dnUVZ8rCdnZ2d@giganews.com>
Hi,

I'm trying to use a version of Paul Graham's aif, specifically the one 
below:

(defmacro aif (test-form then-form &optional else-form (pred nil predp))
  "Anaphoric IF:  Binds the symbol `it' to the value of the `test.'"
  `(let ((it ,test-form))
     (if ,(if predp `(funcall ,pred it) 'it)
       ,then-form ,else-form)))

Which I'm sure is right, since I cribbed it from the metabang utilities. 
Now the thing is, I plonked this in a utils.lisp file in a current 
project, after a line saying (in-package :utils), where defpackage has 
been done as usual and I've exported aif.

However, when I try to _use_ aif in a different package, which 
imports :utils, I have the following problem:

> (macroexpand-1 '(aif (= 1 1) it nil))
(LET ((UTILS::IT (= 1 1)))
  (IF UTILS::IT IT NIL))

So of course, running (aif (= 1 1) it nil) throws an error, since 
UTILS:IT has been declared and "IT" in this package hasn't (I think). I'm 
sure I'm doing something silly though since, for example, aif from the 
metautilities package is used all over the place in cl-graph, seemingly 
in exactly the same way.

Can anyone tell me what I did wrong?

Thanks

Rupert

From: Frode Vatvedt Fjeld
Subject: Re: AIF and scoping problem (I think)
Date: 
Message-ID: <2hwsnnrqbo.fsf@vserver.cs.uit.no>
Rupert Swarbrick <··········@gmail.com> writes:

> Can anyone tell me what I did wrong?

You didn't also export utils:it.

-- 
Frode Vatvedt Fjeld
From: Rupert Swarbrick
Subject: Re: AIF and scoping problem (I think)
Date: 
Message-ID: <DOqdnUxhUMe7eXHanZ2dnUVZ8rCdnZ2d@giganews.com>
On Fri, 28 Mar 2008 13:22:19 +0100, Frode Vatvedt Fjeld wrote:

> Rupert Swarbrick <··········@gmail.com> writes:
> 
>> Can anyone tell me what I did wrong?
> 
> You didn't also export utils:it.

Ahah. Thanks!

Rupert
From: Ron Garret
Subject: Re: AIF and scoping problem (I think)
Date: 
Message-ID: <rNOSPAMon-7452FC.00282929032008@news.gha.chartermi.net>
In article <··············@vserver.cs.uit.no>,
 Frode Vatvedt Fjeld <······@cs.uit.no> wrote:

> Rupert Swarbrick <··········@gmail.com> writes:
> 
> > Can anyone tell me what I did wrong?
> 
> You didn't also export utils:it.

You didn't use lexicons ;-)

rg