Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.lisp > #32998

Re: symbol-macros -vs- symbol setf-expander

From Kaz Kylheku <847-115-0292@kylheku.com>
Newsgroups comp.lang.lisp
Subject Re: symbol-macros -vs- symbol setf-expander
Date 2019-05-31 04:51 +0000
Organization Aioe.org NNTP Server
Message-ID <20190530214258.24@kylheku.com> (permalink)
References <jwv5zq3eh4i.fsf-monnier+comp.lang.lisp@gnu.org> <20190521125844.749@kylheku.com> <20190522125932.721@kylheku.com> <jwv1s0fd9ej.fsf-monnier+comp.lang.lisp@gnu.org>

Show all headers | View raw


On 2019-05-30, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> In your response, you said that this is like gv-letplace.
>> Thus, isn't gv-letplace what that user is looking for, instead of
>> symbol-macrolet?
>
> Rather it's just that the user pointed out the close relationship
> between the two: you can implement a "place-alias" like your `letplace`
> using `symbol-macrolet` and you can implement `symbol-macrolet` using
> `letplace` (or so I presume, since we could do that with gv.el's
> equivalent to your `letplace`).
>
> So it made me wonder about this design space and whether maybe someone
> has found something that's "more better" than either of the two.

By the way, I have discovered a quick and dirty "worse is better" way to
implement place aliases. It's not 100% correct for all possible places,
but it avoids requiring a "fully expand form" function. It also avoids
registering temporary place expanders over the scope of a form. Thus,
the approach is implementable in Common Lisp.

This is located here:

http://www.kylheku.com/cgit/lisp-snippets/tree/placelet.lisp

The define-setf-expander call in placelet1 is useless and can be
removed. The comments try to explain it.

The idea is when we want to bind a symbol S to a place (P),
what we do instead is obtain the setf expansion for (P) and
bind S to the access form for (P).

The issue is that by doing that, we ignore the store form.
We are relying on the store form being deducible from the
access form; i.e. that the access form is itself a place!

For instance, an expression like (nthcdr 3 foo) might
have an access form that looks like (cdr #:g0027).
The store form will be some (rplaca #:g0027 #:g0031) type
thing, but we ignore it.

Lucky for as, the (cdr #:g0027) form is a place, and so we can
make symbol macro S alias for this place.

The approach will fail if the place has an access form that
is itself not a place. But often, in fact usually I would say,
place access forms are places. So this little hack is fairly practical.

-- 
TXR Programming Lanuage: http://nongnu.org/txr
Music DIY Mailing List:  http://www.kylheku.com/diy
ADA MP-1 Mailing List:   http://www.kylheku.com/mp1

Back to comp.lang.lisp | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

symbol-macros -vs- symbol setf-expander Stefan Monnier <monnier@iro.umontreal.ca> - 2019-05-21 15:46 -0400
  Re: symbol-macros -vs- symbol setf-expander Kaz Kylheku <847-115-0292@kylheku.com> - 2019-05-21 21:25 +0000
    Re: symbol-macros -vs- symbol setf-expander Kaz Kylheku <847-115-0292@kylheku.com> - 2019-05-22 20:07 +0000
      Re: symbol-macros -vs- symbol setf-expander Stefan Monnier <monnier@iro.umontreal.ca> - 2019-05-30 15:40 -0400
        Re: symbol-macros -vs- symbol setf-expander Kaz Kylheku <847-115-0292@kylheku.com> - 2019-05-31 04:51 +0000
          Re: symbol-macros -vs- symbol setf-expander "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-31 16:38 +0200
            Re: symbol-macros -vs- symbol setf-expander Kaz Kylheku <847-115-0292@kylheku.com> - 2019-05-31 18:42 +0000
              Re: symbol-macros -vs- symbol setf-expander "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-31 21:24 +0200
                Re: symbol-macros -vs- symbol setf-expander Kaz Kylheku <847-115-0292@kylheku.com> - 2019-06-01 02:34 +0000
              Re: symbol-macros -vs- symbol setf-expander Stefan Monnier <monnier@iro.umontreal.ca> - 2019-05-31 18:14 -0400
                Re: symbol-macros -vs- symbol setf-expander Kaz Kylheku <847-115-0292@kylheku.com> - 2019-06-01 02:51 +0000
                Re: symbol-macros -vs- symbol setf-expander Stefan Monnier <monnier@iro.umontreal.ca> - 2019-06-02 12:16 -0400
                Re: symbol-macros -vs- symbol setf-expander Kaz Kylheku <847-115-0292@kylheku.com> - 2019-06-03 01:13 +0000
        Re: symbol-macros -vs- symbol setf-expander Stefan Monnier <monnier@iro.umontreal.ca> - 2019-05-31 18:04 -0400
  Re: symbol-macros -vs- symbol setf-expander "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-22 22:00 +0200
    Re: symbol-macros -vs- symbol setf-expander a.daniel.eliason@gmail.com - 2019-05-23 08:10 -0700
      Re: symbol-macros -vs- symbol setf-expander Spiros Bousbouras <spibou@gmail.com> - 2019-05-23 15:22 +0000
        Re: symbol-macros -vs- symbol setf-expander Dimitri Fontaine <dim@tapoueh.org> - 2019-05-23 18:02 +0200
          Re: symbol-macros -vs- symbol setf-expander Spiros Bousbouras <spibou@gmail.com> - 2019-05-23 16:51 +0000
        Re: symbol-macros -vs- symbol setf-expander Kaz Kylheku <847-115-0292@kylheku.com> - 2019-05-23 17:05 +0000
          Re: symbol-macros -vs- symbol setf-expander "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-23 19:26 +0200
  Re: symbol-macros -vs- symbol setf-expander smh <shaflich@gmail.com> - 2019-05-22 18:47 -0700

csiph-web