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


Groups > comp.lang.lisp > #32934

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

From "Pascal J. Bourguignon" <pjb@informatimago.com>
Newsgroups comp.lang.lisp
Subject Re: symbol-macros -vs- symbol setf-expander
Date 2019-05-22 22:00 +0200
Organization Informatimago
Message-ID <m2ftp6mf8f.fsf@despina.home> (permalink)
References <jwv5zq3eh4i.fsf-monnier+comp.lang.lisp@gnu.org>

Show all headers | View raw


Stefan Monnier <monnier@iro.umontreal.ca> writes:

> While discussing some extension to Elisp's `gv`, someone pointed out
> that symbol-macros basically allow you to define a symbol as an
> arbitrary "place", i.e. a kind of "place alias".
>
> Yet, it's subtly different since
>
>     (symbol-macrolet ((x (nth 5 (get-list)))) ...)
>     
> will re-execute (get-list) (and `nthcdr 5`) everytime `x` is used
> without offering any easy way to take advantage of the setf-expander
> infrastructure's ability to do those computations only once.
>
> Does anyone here know of work related to this, e.g. discussions about
> the detailed semantics of symbol-macrolet?

You're wrong.  You can see that the macroexpansion uses
get-setf-expander, which takes care of evaluating (get-list) only once:

cl-user> (defmacro m (&environment env) `',(macroexpand-1 '(incf x) env))
m
cl-user> (symbol-macrolet ((x (nth 5 (get-list)))) (m))
(let* ((#:g67596 (get-list)) (#:g67597 1) (#:g67595 (+ (nth 5 #:g67596) #:g67597))) (ccl::%setnth 5 #:g67596 #:g67595))
cl-user>


-- 
__Pascal J. Bourguignon__
http://www.informatimago.com

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