From: Bryant Brandon
Subject: symbol-macrolet question (evil)
Date: 
Message-ID: <10A21F41F1FA4C92.A2C48D498C78FA7B.A27DCA44A3367EDD@library-proxy.airnews.net>
   I need load a series of files with certain macros defined.  What I have now

(let ((var val))
  (declare (special var))
  (dolist (file (get-my-files))
    (load file)))

   This works, but "val" is evaluated immediately.  I would like to have
evaluation delayed so that each file can have a customized expansion based
on *load-pathname*.  But if I change it to

(symbol-macrolet ((mac val))
  ;(declare (special mac)) has no effect here
  (dolist (file (get-my-files))
    (load file)))

   Then "mac" is not bound when a file is loading.
   Is there a workaround?

-- 
B.B.       --I am not a goat!

From: Barry Margolin
Subject: Re: symbol-macrolet question (evil)
Date: 
Message-ID: <SQ_i1.32$Q37.695952@cam-news-reader1.bbnplanet.com>
In article <··················································@library-proxy.airnews.net>,
Bryant Brandon <········@airmail.net> wrote:
>   I need load a series of files with certain macros defined.  What I have now
>
>(let ((var val))
>  (declare (special var))
>  (dolist (file (get-my-files))
>    (load file)))
>
>   This works, but "val" is evaluated immediately.  I would like to have
>evaluation delayed so that each file can have a customized expansion based
>on *load-pathname*.  But if I change it to
>
>(symbol-macrolet ((mac val))
>  ;(declare (special mac)) has no effect here
>  (dolist (file (get-my-files))
>    (load file)))
>
>   Then "mac" is not bound when a file is loading.
>   Is there a workaround?

The reason for this failure is that SYMBOL-MACROLET creates a lexical macro
binding.

How about:

(dolist (file (get-my-files))
  (let ((var val))
    (declare (special var))
    (load file)))

I assume "val" is actually an expression that uses FILE.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
From: Bryant Brandon
Subject: Re: symbol-macrolet question (evil)
Date: 
Message-ID: <6FE794343CFDB258.1A281041AD667EBF.950416FC4312EBCF@library-proxy.airnews.net>
In article <···················@cam-news-reader1.bbnplanet.com>, Barry
Margolin <······@bbnplanet.com> wrote:

[...]

@The reason for this failure is that SYMBOL-MACROLET creates a lexical macro
@binding.
@
@How about:
@
@(dolist (file (get-my-files))
@  (let ((var val))
@    (declare (special var))
@    (load file)))
@
@I assume "val" is actually an expression that uses FILE.

   Hmm, I could do that, but it would require a heafty rewrite of several
heafty things.  (the code I posted is _very_ condensed)  I'm hoping to
find a way to hold off evaluation until the file is loaded.  Not just
because it'd make life easier for me, but I may later want an expression
that will rely on something else unforseen.  A macro would be best for
this situation.
   So, I am seeking a way, no matter how complex, to define a symbol-macro
that will be seen when I load a file.  Is there a way to define a set of
global symbol-macros, saving any that might already exist rather than
replacing them; load the file; and then remove those macros, restoring the
old if they exist?  I'm sure it'll take a disgustingly big and messy
macro, but I have a lot of time on my hands right now.  /:
   Beleive it or not, that would be easier than placing the (let...)
within the (dolist .....).

-- 
B.B.       --I am not a goat!
From: Barry Margolin
Subject: Re: symbol-macrolet question (evil)
Date: 
Message-ID: <EWij1.46$Q37.1081607@cam-news-reader1.bbnplanet.com>
In article <··················································@library-proxy.airnews.net>,
Bryant Brandon <········@airmail.net> wrote:
>   So, I am seeking a way, no matter how complex, to define a symbol-macro
>that will be seen when I load a file.  Is there a way to define a set of
>global symbol-macros, saving any that might already exist rather than
>replacing them; load the file; and then remove those macros, restoring the
>old if they exist?  I'm sure it'll take a disgustingly big and messy
>macro, but I have a lot of time on my hands right now.  /:
>   Beleive it or not, that would be easier than placing the (let...)
>within the (dolist .....).

How about just using DEFINE-SYMBOL-MACRO rather than SYMBOL-MACROLET:

(dolist (file (get-my-files))
  (declare (special file))
  (define-symbol-macro ...)
  (load file))

This will have a side effect of leaving the last one define when you're
done, but perhaps you can live with that.

Another issue: If the files you're loading are already compiled, macros and
symbol macros won't be expanded when you load it.

Finally, I think there's something wrong with your design if it requires
this convoluted implementation.  What is it you're really trying to
accomplish, and why do it this way?  Why do you need a symbol macro for
this?

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
From: Bryant Brandon
Subject: Re: symbol-macrolet question (evil)
Date: 
Message-ID: <E7CDE01E6538D140.70B45FD802F9B5F2.16A4715E154B0111@library-proxy.airnews.net>
In article <····················@cam-news-reader1.bbnplanet.com>, Barry
Margolin <······@bbnplanet.com> wrote:

[...]

@Another issue: If the files you're loading are already compiled, macros and
@symbol macros won't be expanded when you load it.

   They're not compiled, just *.lisp text files.

@Finally, I think there's something wrong with your design if it requires
@this convoluted implementation.  What is it you're really trying to
@accomplish, and why do it this way?  Why do you need a symbol macro for
@this?

   I have a sreies of files which are executed to build other files. 
There is a main build script which whill step through the directory,
loading each file sequentially.  But before it loads the files, it will
look for a conf.lisp file and load that if possible.  The conf file will
contain a big macro, (with-symbols ....) which defines a bunch of symbols,
loads all the files, and then loads all the subdirectories in the same
way.  The files use these symbols.
   The whole system works just fine now, but I'd like to make it a teeny
bit more flexible.  Being able to hold off evaluation until while the
files are loading would do that.
   And I need something to do while I'm stuck in the house.

-- 
B.B.       --I am not a goat!
From: Barry Margolin
Subject: Re: symbol-macrolet question (evil)
Date: 
Message-ID: <Khlj1.2$J3.11429@cam-news-reader1.bbnplanet.com>
In article <··················································@library-proxy.airnews.net>,
Bryant Brandon <········@airmail.net> wrote:
>   The whole system works just fine now, but I'd like to make it a teeny
>bit more flexible.  Being able to hold off evaluation until while the
>files are loading would do that.

The normal way to "hold off evaluation" is to pass a functional argument.
SYMBOL-MACROLET seems like a very contorted solution.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
From: Bryant Brandon
Subject: Re: symbol-macrolet question (evil)
Date: 
Message-ID: <9D5B139C9EC2564C.1910739544373A69.11D3202C98A56C66@library-proxy.airnews.net>
In article <················@cam-news-reader1.bbnplanet.com>, Barry
Margolin <······@bbnplanet.com> wrote:

[...]

@The normal way to "hold off evaluation" is to pass a functional argument.
@SYMBOL-MACROLET seems like a very contorted solution.

   Umm, I didn't think of that.
   God, I feel stupid!  Thanks! (:

-- 
B.B.       --I am not a goat!