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


Groups > comp.lang.lisp > #60777 > unrolled thread

slot-value-using-class to remap "virtual" slots & closer-mop

Started byMadhu <enometh@meer.net>
First post2026-04-25 20:35 +0530
Last post2026-06-19 22:00 -0400
Articles 17 on this page of 37 — 8 participants

Back to article view | Back to comp.lang.lisp


Contents

  slot-value-using-class to remap "virtual" slots & closer-mop Madhu <enometh@meer.net> - 2026-04-25 20:35 +0530
    Re: slot-value-using-class to remap "virtual" slots & closer-mop tfb <no_email@invalid.invalid> - 2026-04-25 18:27 +0000
    Re: slot-value-using-class to remap "virtual" slots & closer-mop Madhu <enometh@meer.net> - 2026-05-07 05:22 +0530
      Re: slot-value-using-class to remap "virtual" slots & closer-mop Stefan Monnier <monnier@iro.umontreal.ca> - 2026-05-07 15:14 -0400
        Re: slot-value-using-class to remap "virtual" slots & closer-mop Madhu <enometh@meer.net> - 2026-05-08 09:48 +0530
          Re: slot-value-using-class to remap "virtual" slots & closer-mop steve g <sgonedes1977@gmail.com> - 2026-06-02 21:50 -0400
            Re: slot-value-using-class to remap "virtual" slots & closer-mop Madhu <enometh@meer.net> - 2026-06-03 09:21 +0530
              Re: slot-value-using-class to remap "virtual" slots & closer-mop steve g <sgonedes1977@gmail.com> - 2026-06-03 22:48 -0400
              Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-04 03:22 +0000
                Re: slot-value-using-class to remap "virtual" slots & closer-mop steve g <sgonedes1977@gmail.com> - 2026-06-04 17:01 -0400
                  Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-04 22:42 +0000
                    Re: slot-value-using-class to remap "virtual" slots & closer-mop Madhu <enometh@meer.net> - 2026-06-08 04:13 +0530
                      Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-07 23:22 +0000
                        Re: slot-value-using-class to remap "virtual" slots & closer-mop tfb <no_email@invalid.invalid> - 2026-06-08 07:52 +0000
                        Re: slot-value-using-class to remap "virtual" slots & closer-mop Paul Rubin <no.email@nospam.invalid> - 2026-06-13 12:41 -0700
                          Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-14 01:04 +0000
                            Re: slot-value-using-class to remap "virtual" slots & closer-mop Paul Rubin <no.email@nospam.invalid> - 2026-06-14 01:48 -0700
                              Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-14 23:52 +0000
                                Re: slot-value-using-class to remap "virtual" slots & closer-mop Paul Rubin <no.email@nospam.invalid> - 2026-06-14 17:31 -0700
                                  Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-16 00:14 +0000
                      Re: slot-value-using-class to remap "virtual" slots & closer-mop steve g <Sgonedes1977@gmail.com> - 2026-06-19 22:05 -0400
                    Re: slot-value-using-class to remap "virtual" slots & closer-mop steve g <Sgonedes1977@gmail.com> - 2026-06-19 22:04 -0400
                Re: slot-value-using-class to remap "virtual" slots & closer-mop tfb <no_email@invalid.invalid> - 2026-06-07 16:42 +0000
                  Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-07 23:24 +0000
                    Re: slot-value-using-class to remap "virtual" slots & closer-mop Nuno Silva <nunojsilva@invalid.invalid> - 2026-06-08 00:57 +0100
                      Re: slot-value-using-class to remap "virtual" slots & closer-mop Stefan Monnier <monnier@iro.umontreal.ca> - 2026-06-08 09:25 -0400
                        Re: slot-value-using-class to remap "virtual" slots & closer-mop Nuno Silva <nunojsilva@invalid.invalid> - 2026-06-15 10:22 +0100
              Re: slot-value-using-class to remap "virtual" slots & closer-mop tfb <no_email@invalid.invalid> - 2026-06-07 16:31 +0000
                Re: slot-value-using-class to remap "virtual" slots & closer-mop Paul Rubin <no.email@nospam.invalid> - 2026-06-07 12:31 -0700
                  Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-08 02:27 +0000
                    Re: slot-value-using-class to remap "virtual" slots & closer-mop tfb <no_email@invalid.invalid> - 2026-06-08 07:36 +0000
                      Re: slot-value-using-class to remap "virtual" slots & closer-mop Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-09 00:30 +0000
                        Re: slot-value-using-class to remap "virtual" slots & closer-mop steve g <sgonedes1977@gmail.com> - 2026-06-09 00:25 -0400
                        Re: slot-value-using-class to remap "virtual" slots & closer-mop tfb <no_email@invalid.invalid> - 2026-06-09 05:49 +0000
                Re: slot-value-using-class to remap "virtual" slots & closer-mop Madhu <enometh@meer.net> - 2026-06-08 04:06 +0530
                Re: slot-value-using-class to remap "virtual" slots & closer-mop steve g <Sgonedes1977@gmail.com> - 2026-06-19 23:10 -0400
    Re: slot-value-using-class to remap "virtual" slots & closer-mop steve g <Sgonedes1977@gmail.com> - 2026-06-19 22:00 -0400

Page 2 of 2 — ← Prev page 1 [2]


#60998

Fromsteve g <Sgonedes1977@gmail.com>
Date2026-06-19 22:05 -0400
Message-ID<87a4sqhsp6.fsf@gmail.com>
In reply to#60811
Madhu <enometh@meer.net> writes:

> * Lawrence D’Oliveiro <10vsuvs$nejc$4@dont-email.me> :
> Wrote on Thu, 4 Jun 2026 22:42:04 -0000 (UTC):
>>> yes and no. setf if a fat macro, setq is preferable to set.
>>
>> Why “preferable”? Seems to me you have less to worry about in terms of
>> special cases if you just use setf.
>
> Here we go again.
>
> SETQ modified bindings. variable bindings.
>
> SETF is a generalized mechanism to modify "places" (which includes
> variable bindings)
>
> using SETQ signals that there is nothing complicated going on under the
> surface syntax. EXCEPT IN SYMBOL-MACROLET where it is defined to work as
> SETF, which is the context in which I made the **** comment



thank you for your elegant explanation.

[toc] | [prev] | [next] | [standalone]


#60997

Fromsteve g <Sgonedes1977@gmail.com>
Date2026-06-19 22:04 -0400
Message-ID<87eci2hsqg.fsf@gmail.com>
In reply to#60805
Lawrence D’Oliveiro <ldo@nz.invalid> writes:

> On Thu, 04 Jun 2026 17:01:51 -0400, steve g wrote:
>
>> Lawrence D’Oliveiro <ldo@nz.invalid> writes:
>>
>>> Can’t you use setf for assigning to everything?
>>
>> yes and no. setf if a fat macro, setq is preferable to set.
>
> Why “preferable”? Seems to me you have less to worry about in terms of
> special cases if you just use setf.


I am not going into the specifics tonight. I am rebuilding my antenna.

[toc] | [prev] | [next] | [standalone]


#60808

Fromtfb <no_email@invalid.invalid>
Date2026-06-07 16:42 +0000
Message-ID<110471b$2l3uf$1@dont-email.me>
In reply to#60803
Lawrence D´Oliveiro <ldo@nz.invalid> wrote:

> Can’t you use setf for assigning to everything?
> 

Yes.  It has no runtime cost, the whole 'fat macro' someone mentioned is
confused.  In particular (setf (symbol-value x) y) and(set x y) are
entirely the same thing.  You never need to use SET or SETQ (or RPLACA, or
...) unless you want your programs to have that vintage charm.  Things that
arrived (or were heavily modified) in CL don't even have update functions:
there's no ASET for instance.

-- 
www.tfeb.org/computer/

[toc] | [prev] | [next] | [standalone]


#60813

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-07 23:24 +0000
Message-ID<1104uio$2rlf4$5@dont-email.me>
In reply to#60808
On Sun, 7 Jun 2026 16:42:19 -0000 (UTC), tfb wrote:

> ... unless you want your programs to have that vintage charm.

:)

[toc] | [prev] | [next] | [standalone]


#60814

FromNuno Silva <nunojsilva@invalid.invalid>
Date2026-06-08 00:57 +0100
Message-ID<11050hn$2rflv$2@dont-email.me>
In reply to#60813
On 2026-06-08, Lawrence D’Oliveiro wrote:

> On Sun, 7 Jun 2026 16:42:19 -0000 (UTC), tfb wrote:
>
>> ... unless you want your programs to have that vintage charm.
>
> :)

That's what terminals are for. You may be limited by lack of UCS
coverage, but you can perhaps get a "vintage charm" out of the coding
experience :-)

(Some years ago, I did write one MSc thesis partially using a terminal,
LaTeX on Emacs. It tended to be an ergonomic setup for me. It didn't
involve Lisp code, though.)

-- 
Nuno Silva

[toc] | [prev] | [next] | [standalone]


#60822

FromStefan Monnier <monnier@iro.umontreal.ca>
Date2026-06-08 09:25 -0400
Message-ID<jwvldcpnp1v.fsf-monnier+comp.lang.lisp@gnu.org>
In reply to#60814
> (Some years ago, I [...] using [...] on Emacs.
> [...] It didn't involve Lisp code, though.)

🙃


=== Stefan

[toc] | [prev] | [next] | [standalone]


#60905

FromNuno Silva <nunojsilva@invalid.invalid>
Date2026-06-15 10:22 +0100
Message-ID<110og8p$7l4s$3@dont-email.me>
In reply to#60822
On 2026-06-08, Stefan Monnier wrote:

>> (Some years ago, I [...] using [...] on Emacs.
>> [...] It didn't involve Lisp code, though.)
> 🙃

Yes, yes, I mean the thesis itself didn't have Lisp code :-)

(You wouldn't believe how hard it was for me to see what was in that
glyph!)

-- 
Nuno Silva

[toc] | [prev] | [next] | [standalone]


#60807

Fromtfb <no_email@invalid.invalid>
Date2026-06-07 16:31 +0000
Message-ID<11046ce$2ktnj$1@dont-email.me>
In reply to#60801
Madhu <enometh@meer.net> wrote:
> 
> *
> it's the greatest thing because you can use SETQ
> instead of SETF.
> 

Uh, is this some joke I am missing?  Do people really still use SETQ?  Do
they think it is somehow an advantage?  If so, how?

-- 
www.tfeb.org/computer/

[toc] | [prev] | [next] | [standalone]


#60809

FromPaul Rubin <no.email@nospam.invalid>
Date2026-06-07 12:31 -0700
Message-ID<877boa9mgg.fsf@nightsong.com>
In reply to#60807
tfb <no_email@invalid.invalid> writes:
> Uh, is this some joke I am missing?  Do people really still use SETQ?  Do
> they think it is somehow an advantage?  If so, how?

I've used it because I was used to it from Emacs Lisp and I had it in a
special purpose non-CL Lisp that I wrote a while back.  Maybe both count
as "vintage charm".  Yeah SETF in CL is more idiomatic.

[toc] | [prev] | [next] | [standalone]


#60815

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-08 02:27 +0000
Message-ID<11059b8$2u485$1@dont-email.me>
In reply to#60809
On Sun, 07 Jun 2026 12:31:27 -0700, Paul Rubin wrote:

> I've used [setq] because I was used to it from Emacs Lisp ..

Emacs lisp supports setf.

Yes, I have the habit of using setq, too ...

[toc] | [prev] | [next] | [standalone]


#60816

Fromtfb <no_email@invalid.invalid>
Date2026-06-08 07:36 +0000
Message-ID<1105rek$329uh$1@dont-email.me>
In reply to#60815
Lawrence D´Oliveiro <ldo@nz.invalid> wrote:
> 
> Emacs lisp supports setf.

It does now, it didn't.  I'd certainly use setq if I had to write elisp
again.
 
-- 
www.tfeb.org/computer/

[toc] | [prev] | [next] | [standalone]


#60824

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-09 00:30 +0000
Message-ID<1107mr0$3k6ea$4@dont-email.me>
In reply to#60816
On Mon, 8 Jun 2026 07:36:52 -0000 (UTC), tfb wrote:

> Lawrence D´Oliveiro <ldo@nz.invalid> wrote:
>>
>> Emacs lisp supports setf.
>
> It does now, it didn't. I'd certainly use setq if I had to write
> elisp again.

When did you last do so?

[toc] | [prev] | [next] | [standalone]


#60829

Fromsteve g <sgonedes1977@gmail.com>
Date2026-06-09 00:25 -0400
Message-ID<87ldcoxrup.fsf@gmail.com>
In reply to#60824
Lawrence D’Oliveiro <ldo@nz.invalid> writes:

> On Mon, 8 Jun 2026 07:36:52 -0000 (UTC), tfb wrote:
>
< > Lawrence D´Oliveiro <ldo@nz.invalid> wrote:
< >>
< >> Emacs lisp supports setf.
< >
< > It does now, it didn't. I'd certainly use setq if I had to write
< > elisp again.
>
> When did you last do so?


I just read a book on AI algos...

[toc] | [prev] | [next] | [standalone]


#60831

Fromtfb <no_email@invalid.invalid>
Date2026-06-09 05:49 +0000
Message-ID<11089h6$3oj2a$1@dont-email.me>
In reply to#60824
Lawrence D´Oliveiro <ldo@nz.invalid> wrote:

> 
> When did you last do so?
> 

last commit to my elisp repo was early 2025, the previous one was early
2024.  Pretty much these are adjustments for new versions of emacs or macos
lossage.  The last time I wrote anything seriously was likely two decades
ago now.

-- 
www.tfeb.org/computer/

[toc] | [prev] | [next] | [standalone]


#60810

FromMadhu <enometh@meer.net>
Date2026-06-08 04:06 +0530
Message-ID<m3tsre0yhy.fsf@pison.robolove.meer.net>
In reply to#60807
* tfb <11046ce$2ktnj$1@dont-email.me> :
Wrote on Sun, 7 Jun 2026 16:31:10 -0000 (UTC):

>> it's the greatest thing because you can use SETQ
>> instead of SETF.
> Uh, is this some joke I am missing?  Do people really still use SETQ?  Do
> they think it is somehow an advantage?  If so, how?

freedom of choice.   s w e e t     f r e e e d o m

coming from english perhaps you can appreciate nuances of usage: the
distinction between "a" and "an" before words, and the and how it sounds
when non-natives[2] elide[1] the distinction

1 original sense of elide,
2 non-native speakers of course (I am one)

[toc] | [prev] | [next] | [standalone]


#61000

Fromsteve g <Sgonedes1977@gmail.com>
Date2026-06-19 23:10 -0400
Message-ID<875x3dj4ad.fsf@gmail.com>
In reply to#60807
tfb <no_email@invalid.invalid> writes:

> Madhu <enometh@meer.net> wrote:
>> 
>> *
>> it's the greatest thing because you can use SETQ
>> instead of SETF.
>> 
>
> Uh, is this some joke I am missing?  Do people really still use SETQ?  Do
> they think it is somehow an advantage?  If so, how?


yes. I believe the biggest difference is in the letter q or f.


; SLIME 2.27
CL-USER> (macroexpand-1 '(setq abc 123))
(SETQ ABC 123)
NIL
CL-USER> (macroexpand-1 '(setf abc 123))
(SETQ ABC 123)
T
CL-USER> 

[toc] | [prev] | [next] | [standalone]


#60996

Fromsteve g <Sgonedes1977@gmail.com>
Date2026-06-19 22:00 -0400
Message-ID<87ik7ehsxo.fsf@gmail.com>
In reply to#60777
Madhu <enometh@meer.net> writes:

> I had occasion to want to have certain slot-value accesses "redirect" to
> other slots, so accessing one would seem to affect the other.

I am thinking of letf. i will post it again. the cmucl version is
probably better...


(defmacro letf (forms &body body &environment env)
  (flet ((make-vars (count)
           (loop repeat count collect (gensym)))
         (equal-gensyms (x y)
           (if (and (symbolp x) (symbolp y))
			   (or (string= x y)        ; this seems to work, probably compares symbol-name
                   ;; this should be first test
                   (string= (symbol-name x) (symbol-name y)))
			   (equalp x y)))
         (extract-setf-subforms (forms)
           (mapcar #'(lambda (form)
             (if (null (cddr form))
                 (cadr form)
                 (error 'program-error
                  :format-arguments (list (cdr form))
                  :format-control
                  "~@<Odd number of subforms to setf: ~_~:w.~:@>")))
             forms)))

    (let ((getters ()) (getvars ())
          (setters ()) (storevars ())
          (valuevars (make-vars (length forms)))
          (valueforms (extract-setf-subforms forms)))
      (dolist (form forms)
        (multiple-value-bind (vars vals store-vars writer-form reader-form)
            (get-setf-expansion (car form) env)
          (setq getvars (nconc (mapcar #'list vars vals) getvars))
          (push reader-form getters)
          (push writer-form setters)
          (if (cdr store-vars)
              (error 'program-error
                :format-control "~@<Cannot expand form: ~_~:w.~:@>"
                :format-arguments (list form))
              (push (car store-vars) storevars))))

      (labels ((unroll-body (tempsetters body resetters)
                 (cond ((endp tempsetters)
                        (cons 'progn body))
                       (t `(unwind-protect
                      (progn ,(car tempsetters)
                        ,(unroll-body (cdr tempsetters) body (cdr resetters)))
                    ,(car resetters))))))

        (let ((tempsetters
             (sublis (pairlis storevars valuevars)
                setters :test #'equal-gensyms)))

        `(let* (
                ,@(mapcar #'list valuevars valueforms)
                ,@getvars
                ,@(mapcar #'list storevars getters))
           ,(unroll-body tempsetters body setters)))))))



LETF
CL-USER> (defvar *tart* (make-tart :numval 3 :chr-val #\z))
CL-USER> *tart*
#S(TART :NUMVAL 3 :CHRVAL #\d)
CL-USER> (progn
           (letf (((tart-numval *tart*) 37)
                  ((tart-chrval *tart*) #\z))
             (pprint *tart*))
           (pprint *tart*))

#S(TART :NUMVAL #\z :CHRVAL 37)
#S(TART :NUMVAL 3 :CHRVAL #\d)
; No value


this is the best idea I know of; and this idea is risky in my opinion.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.lisp


csiph-web