If I do this:
(defmacro current-env (&environment env) env)
then I can capture a "macro closure" that allows me to expand macros
defined by macrolet outside the lexical scope of that macrolet, e.g.:
(setf e (macrolet ((foo (x) `(cons ',x ',x))) (current-env)))
(macroexpand '(foo baz) e) --> (CONS 'BAZ 'BAZ)
Is there any way to portably augment one of these lexical environment
objects with additional definitions? I'd like to be able to do
something like:
(with-lexical-environment e
(macrolet ((baz () (foo 'snoz))
(current-env)))
and get an environment where (baz) expands to (cons 'snoz 'snoz).
Is that possible in portable CL?
rg
|
|
0
|
|
|
|
Reply
|
rNOSPAMon (1856)
|
8/28/2006 6:59:06 PM |
|
Ron Garret <rNOSPAMon@flownet.com> wrote:
> If I do this:
>
> (defmacro current-env (&environment env) env)
>
> then I can capture a "macro closure"
No, you cannot (portably) capture the environment. The object to which
ENV is bound has dynamic extent. See 3.4.4:
<URL:http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm>
> Is there any way to portably augment one of these lexical environment
> objects with additional definitions?
I don't think so. Isn't that the point of Franz's/Duane Rettig's
environment access proposal (and in the case of ACL, implementation)?
> I'd like to be able to do something like:
>
> (with-lexical-environment e
> (macrolet ((baz () (foo 'snoz))
> (current-env)))
>
> and get an environment where (baz) expands to (cons 'snoz 'snoz).
>
> Is that possible in portable CL?
I believe not.
--
Duncan Harvey
|
|
0
|
|
|
|
Reply
|
usenet-2006-04 (18)
|
8/28/2006 7:33:32 PM
|
|
In article <1hksrfp.k53ycv1dmsq0uN%usenet-2006-04@abbrvtd.org.uk>,
usenet-2006-04@abbrvtd.org.uk (Duncan Harvey) wrote:
> Ron Garret <rNOSPAMon@flownet.com> wrote:
>
> > If I do this:
> >
> > (defmacro current-env (&environment env) env)
> >
> > then I can capture a "macro closure"
>
> No, you cannot (portably) capture the environment. The object to which
> ENV is bound has dynamic extent. See 3.4.4:
>
> <URL:http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm>
Oh. Bummer.
rg
|
|
0
|
|
|
|
Reply
|
rNOSPAMon (1856)
|
8/28/2006 7:47:19 PM
|
|
Ron Garret <rNOSPAMon@flownet.com> wrote:
> In article <1hksrfp.k53ycv1dmsq0uN%usenet-2006-04@abbrvtd.org.uk>,
> usenet-2006-04@abbrvtd.org.uk (Duncan Harvey) wrote:
>
> > Ron Garret <rNOSPAMon@flownet.com> wrote:
> >
> > > If I do this:
> > >
> > > (defmacro current-env (&environment env) env)
> > >
> > > then I can capture a "macro closure"
> >
> > No, you cannot (portably) capture the environment. The object to which
> > ENV is bound has dynamic extent. See 3.4.4:
> >
> > <URL:http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm>
>
> Oh. Bummer.
If you're interested in AUGMENT-ENVIRONMENT capabilities, could you not
write as much of Environment Access-style as you need specifically for
the implementations you want? Thereby creating a portability layer for
yourself. If the implementations you use expose the underlying
functionality, albeit idiosyncratically, it might be easier than
attempting to code it portably (had that been possible).
OTOH if you you actually wanted to capture these kinds of environment
indefinitely, then, yeah, bummer.
--
Duncan Harvey
|
|
0
|
|
|
|
Reply
|
usenet-2006-04 (18)
|
8/28/2006 8:42:22 PM
|
|
Ron Garret <rNOSPAMon@flownet.com> wrote:
> In article <1hksrfp.k53ycv1dmsq0uN%usenet-2006-04@abbrvtd.org.uk>,
> usenet-2006-04@abbrvtd.org.uk (Duncan Harvey) wrote:
>
> > Ron Garret <rNOSPAMon@flownet.com> wrote:
> >
> > > If I do this:
> > >
> > > (defmacro current-env (&environment env) env)
> > >
> > > then I can capture a "macro closure"
> >
> > No, you cannot (portably) capture the environment. The object to which
> > ENV is bound has dynamic extent. See 3.4.4:
> >
> > <URL:http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm>
>
> Oh. Bummer.
If you're interested in AUGMENT-ENVIRONMENT capabilities, could you not
write as much of Environment Access as you need specifically for the
implementations you want? Thereby creating a portability layer for
yourself. If the implementations you use expose the underlying
functionality, albeit idiosyncratically, it might be easier than
attempting to code it portably (had that been possible).
OTOH if you you actually wanted to capture these kinds of environment
indefinitely, then, yeah, bummer.
--
Duncan Harvey
|
|
0
|
|
|
|
Reply
|
usenet-2006-04 (18)
|
8/28/2006 8:53:18 PM
|
|
In article <1hksssh.1tqvj3z1fpn8owN%usenet-2006-04@abbrvtd.org.uk>,
usenet-2006-04@abbrvtd.org.uk (Duncan Harvey) wrote:
> Ron Garret <rNOSPAMon@flownet.com> wrote:
>
> > In article <1hksrfp.k53ycv1dmsq0uN%usenet-2006-04@abbrvtd.org.uk>,
> > usenet-2006-04@abbrvtd.org.uk (Duncan Harvey) wrote:
> >
> > > Ron Garret <rNOSPAMon@flownet.com> wrote:
> > >
> > > > If I do this:
> > > >
> > > > (defmacro current-env (&environment env) env)
> > > >
> > > > then I can capture a "macro closure"
> > >
> > > No, you cannot (portably) capture the environment. The object to which
> > > ENV is bound has dynamic extent. See 3.4.4:
> > >
> > > <URL:http://www.lispworks.com/documentation/HyperSpec/Body/03_dd.htm>
> >
> > Oh. Bummer.
>
> If you're interested in AUGMENT-ENVIRONMENT capabilities, could you not
> write as much of Environment Access-style as you need specifically for
> the implementations you want?
Yes, I could do that, but I was hoping I wouldn't have to.
rg
|
|
0
|
|
|
|
Reply
|
rNOSPAMon (1856)
|
8/28/2006 9:09:31 PM
|
|
Ron Garret wrote:
> If I do this:
>
> (defmacro current-env (&environment env) env)
>
> then I can capture a "macro closure" that allows me to expand macros
> defined by macrolet outside the lexical scope of that macrolet, e.g.:
>
> (setf e (macrolet ((foo (x) `(cons ',x ',x))) (current-env)))
> (macroexpand '(foo baz) e) --> (CONS 'BAZ 'BAZ)
>
> Is there any way to portably augment one of these lexical environment
> objects with additional definitions? I'd like to be able to do
> something like:
>
> (with-lexical-environment e
> (macrolet ((baz () (foo 'snoz))
> (current-env)))
>
> and get an environment where (baz) expands to (cons 'snoz 'snoz).
>
> Is that possible in portable CL?
Yes, it is, but it's not straightforward. I have an implementation (or
better: something very close), and I hope I will be able to describe it
soon. (Waiting for the ILC CfP...)
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
|
|
0
|
|
|
|
Reply
|
pc56 (3896)
|
8/28/2006 9:57:31 PM
|
|
In article <4lh76bF1uoi2U1@individual.net>,
Pascal Costanza <pc@p-cos.net> wrote:
> Ron Garret wrote:
> > If I do this:
> >
> > (defmacro current-env (&environment env) env)
> >
> > then I can capture a "macro closure" that allows me to expand macros
> > defined by macrolet outside the lexical scope of that macrolet, e.g.:
> >
> > (setf e (macrolet ((foo (x) `(cons ',x ',x))) (current-env)))
> > (macroexpand '(foo baz) e) --> (CONS 'BAZ 'BAZ)
> >
> > Is there any way to portably augment one of these lexical environment
> > objects with additional definitions? I'd like to be able to do
> > something like:
> >
> > (with-lexical-environment e
> > (macrolet ((baz () (foo 'snoz))
> > (current-env)))
> >
> > and get an environment where (baz) expands to (cons 'snoz 'snoz).
> >
> > Is that possible in portable CL?
>
> Yes, it is, but it's not straightforward. I have an implementation (or
> better: something very close), and I hope I will be able to describe it
> soon. (Waiting for the ILC CfP...)
>
>
> Pascal
I know you have an approach where you shadow macrolet and maintain a
user-accessible lexical environment in parallel with the one the system
keeps. But I was hoping not to have to reinvent that wheel (though I
suppose if you're doing it for me that's good enough for my purposes ;-)
BTW, have you had a chance to look at the lexicon code?
rg
|
|
0
|
|
|
|
Reply
|
rNOSPAMon (1856)
|
8/28/2006 11:06:29 PM
|
|
Ron Garret wrote:
> In article <4lh76bF1uoi2U1@individual.net>,
> Pascal Costanza <pc@p-cos.net> wrote:
>
>> Ron Garret wrote:
>>> If I do this:
>>>
>>> (defmacro current-env (&environment env) env)
>>>
>>> then I can capture a "macro closure" that allows me to expand macros
>>> defined by macrolet outside the lexical scope of that macrolet, e.g.:
>>>
>>> (setf e (macrolet ((foo (x) `(cons ',x ',x))) (current-env)))
>>> (macroexpand '(foo baz) e) --> (CONS 'BAZ 'BAZ)
>>>
>>> Is there any way to portably augment one of these lexical environment
>>> objects with additional definitions? I'd like to be able to do
>>> something like:
>>>
>>> (with-lexical-environment e
>>> (macrolet ((baz () (foo 'snoz))
>>> (current-env)))
>>>
>>> and get an environment where (baz) expands to (cons 'snoz 'snoz).
>>>
>>> Is that possible in portable CL?
>> Yes, it is, but it's not straightforward. I have an implementation (or
>> better: something very close), and I hope I will be able to describe it
>> soon. (Waiting for the ILC CfP...)
>>
>>
>> Pascal
>
> I know you have an approach where you shadow macrolet and maintain a
> user-accessible lexical environment in parallel with the one the system
> keeps. But I was hoping not to have to reinvent that wheel (though I
> suppose if you're doing it for me that's good enough for my purposes ;-)
Well, I am not going the whole way, but maybe my code can be used as a
starting point.
> BTW, have you had a chance to look at the lexicon code?
No, haven't found the time.
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
|
|
0
|
|
|
|
Reply
|
pc56 (3896)
|
8/29/2006 2:22:19 PM
|
|
|
8 Replies
32 Views
(page loaded in 0.083 seconds)
Similiar Articles: Delay in C on linux or OSS - comp.lang.c... to run under OSS environment or linux. I would like to implement ... into service to implement simple delays. On MS-DOS machines, it is possible ... There isn't any portable ... Import Scan Images to DICOM as Open Source Application - comp ...Using the MAC is one possible solution (though I heard ... Peter, I know this can be very fun to implement ... paranoid), run executable in some kind of environment ... Which Assembler? - comp.lang.asm.x86... in function but readily accessible - it was possible to ... that most of my programs would be in the Win32 environment. ... How to implement exception handling in linux assembly ... improve strlen - comp.lang.asm.x86Faster way to implement strlen() is to store the length ... writing in assembly.. you get same result in portable ... or "this is better" tend to melt away when the environment ... Segment, Base Address, PM, ... - comp.lang.asm.x86I think I see where I was confused : It is POSSIBLE to ... virtual 8086 tasks) to create a compatible environment ... To implement flat mode, all segment descriptors ... Where did Fortran go? - comp.lang.fortranPDTs, OTOH, are expensive to implement. And ... is an IDE, that is, a development environment ... to handle free-format input in portable code. That was not possible in ... Quick sync between two computers not connected to the internet ...... to establish 'the best that can be possible' in a private > environment ... The easiest way to implement this is to require ... You can use a portable radio clock or ... .g64 images - comp.sys.cbm... within a microsoft-free environment ... the facts, what it means to implement a ... USB interface) and a pretty portable Java application, that makes it possible to ... [comp.publish.cdrom] CD-Recordable FAQ, Part 1/4 - comp.publish ...Archive-name: cdrom/cd-recordable/part1 Posting-Frequency: monthly Last-modified: 2008/10/09 Version: 2.71 Send corrections and updates to And... Sampling: What Nyquist Didn't Say, and What to Do About It - comp ...... tagged with several items from your "writing environment ... And it's always possible to use any one of a gazillion ... > technique now, but a lot of work to implement effectively. Augmented reality - Wikipedia, the free encyclopediaAugmented reality (AR) is a live, direct or ... view of a physical, real-world environment whose elements are augmented by ... advantages of handheld AR is the portable ... C++ - Wikipedia, the free encyclopedia... purpose language that is as efficient and portable ... without a sophisticated programming environment ... Curiously Recurring Template Pattern, it's possible to implement ... 7/19/2012 8:54:34 PM
|