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

    From Madhu@enometh@meer.net to comp.lang.lisp on Sat Apr 25 20:35:29 2026
    From Newsgroup: comp.lang.lisp


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

    (defclass foo ()
    ((slot-1 :initform 10))
    (#+lispworks :optimize-slot-access #+lispworks nil))

    this is the behaviour which is required

    (setq $f (make-instance 'foo))
    (slot-value $f 'slot-1) ; 30
    (setf (slot-value $f 'slot-3) 20)
    (slot-value $f 'slot-1) ; => 30

    here is the expanded boilerplate which maps 'slot-2' and 'slot-3' to
    'slot-1'

    (defmethod c2mop:slot-value-using-class
    ((class standard-class) (obj foo) slot)
    (let ((slot-name
    (etypecase slot
    (symbol slot)
    (c2mop:standard-effective-slot-definition
    (c2mop:slot-definition-name slot)))))
    (case slot-name
    (slot-2 (slot-value obj 'slot-1))
    (slot-3 (slot-value obj 'slot-2))
    (otherwise (call-next-method)))))

    (defmethod (setf c2mop:slot-value-using-class)
    (value (class standard-class) (obj foo) slot)
    (let ((slot-name
    (etypecase slot
    (symbol slot)
    (c2mop:standard-effective-slot-definition
    (c2mop:slot-definition-name slot)))))
    (case slot-name
    (slot-2 (setf (slot-value obj 'slot-1) value))
    (slot-3 (setf (slot-value obj 'slot-2) value))
    (otherwise (call-next-method)))))

    any pitfalls comments or alternative implementations

    i'm using standard-class but maybe i should be using
    c2mop:standard-class (and c2mop:defmethod) instead, i couldn't spot any documentation on closer-mop on how it is to be used, the objects are
    slightly different, and i'm not able to assess if there is an impact
    across implementaions.
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From tfb@no_email@invalid.invalid to comp.lang.lisp on Sat Apr 25 18:27:25 2026
    From Newsgroup: comp.lang.lisp

    Madhu <enometh@meer.net> wrote:


    any pitfalls comments or alternative implementations

    You need a slot-boundp-using-class method at least.

    And to build a package so your code isn't full of package-qualified names, though I realise that's now a list cause. Indeed I am working on an implementation which will require all names to be of the form impl:thing-nobody-understands:version:package:actual-symbol-name. I feel
    this will be wildly successful.
    --
    www.tfeb.org/computer/
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Madhu@enometh@meer.net to comp.lang.lisp on Thu May 7 05:22:45 2026
    From Newsgroup: comp.lang.lisp

    * In <m3ldebnkqu.fsf@pison.robolove.meer.net> :
    I Wrote on Sat, 25 Apr 2026 20:35:29 +0530:

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

    (defclass foo ()
    ((slot-1 :initform 10))
    (#+lispworks :optimize-slot-access #+lispworks nil))

    this is the behaviour which is required

    (setq $f (make-instance 'foo))
    (slot-value $f 'slot-1) ; 30
    ;; should be 10


    (setf (slot-value $f 'slot-3) 20)

    Apparently this only works on lispworks. all other lisps I tried fail at
    this step i.e. accessing the "virtual slot" slot-3, saying the slot does
    not exist.

    since is not found in (class-slots (find-class 'foo)) and the suggested definition of slot-value involves finding the slot in class-slots before passing it to s-v-u-c

    but the goal was to have slot-3 be a "virtual" slot. So I'm back to
    square 1 in trying to implement these "virtual slot redirects"

    (slot-value $f 'slot-1) ; => 30

    here is the expanded boilerplate which maps 'slot-2' and 'slot-3' to
    'slot-1'

    (defmethod c2mop:slot-value-using-class
    ((class standard-class) (obj foo) slot)
    (let ((slot-name
    (etypecase slot
    (symbol slot)
    (c2mop:standard-effective-slot-definition
    (c2mop:slot-definition-name slot)))))
    (case slot-name
    (slot-2 (slot-value obj 'slot-1))
    (slot-3 (slot-value obj 'slot-2))
    (otherwise (call-next-method)))))

    (defmethod (setf c2mop:slot-value-using-class)
    (value (class standard-class) (obj foo) slot)
    (let ((slot-name
    (etypecase slot
    (symbol slot)
    (c2mop:standard-effective-slot-definition
    (c2mop:slot-definition-name slot)))))
    (case slot-name
    (slot-2 (setf (slot-value obj 'slot-1) value))
    (slot-3 (setf (slot-value obj 'slot-2) value))
    (otherwise (call-next-method)))))

    any pitfalls comments or alternative implementations

    i'm using standard-class but maybe i should be using
    c2mop:standard-class (and c2mop:defmethod) instead, i couldn't spot any documentation on closer-mop on how it is to be used, the objects are
    slightly different, and i'm not able to assess if there is an impact
    across implementaions.
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Stefan Monnier@monnier@iro.umontreal.ca to comp.lang.lisp on Thu May 7 15:14:24 2026
    From Newsgroup: comp.lang.lisp

    Apparently this only works on lispworks. all other lisps I tried fail at
    this step i.e. accessing the "virtual slot" slot-3, saying the slot does
    not exist.

    I'm not sure I understand the details of what you're looking for (I get
    the impression that your original example had typos that made it too
    confusing for my little brain), but maybe you can use the
    `slot-missing` method?


    === Stefan
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Madhu@enometh@meer.net to comp.lang.lisp on Fri May 8 09:48:54 2026
    From Newsgroup: comp.lang.lisp

    * Stefan Monnier <jwvcxz7doj6.fsf-monnier+comp.lang.lisp@gnu.org> :
    Wrote on Thu, 07 May 2026 15:14:24 -0400:

    Apparently this only works on lispworks. all other lisps I tried fail at
    this step i.e. accessing the "virtual slot" slot-3, saying the slot does
    not exist.

    I'm not sure I understand the details of what you're looking for (I get
    the impression that your original example had typos that made it too confusing for my little brain), but maybe you can use the
    `slot-missing` method?

    Yes, I was able to replace all that slot-value-using-class machinery
    with slot-missing.

    (defclass foo ()
    ((slot-1 :initform 10 :initarg :slot-1)))

    (defmethod slot-missing ((class standard-class) (obj foo) slot operation
    &optional new-value)
    (let ((slot-name
    (etypecase slot
    (symbol slot)
    (ccl:standard-effective-slot-definition
    (ccl:slot-definition-name slot)))))
    (case slot-name
    (slot-2
    (ecase operation
    (setf (setf (slot-value obj 'slot-1) new-value))
    (slot-boundp (slot-boundp obj 'slot-1))
    (slot-makunbound (slot-makunbound obj 'slot-1))
    (slot-value (slot-value obj 'slot-1))))
    (slot-3
    (ecase operation
    (setf (setf (slot-value obj 'slot-1) new-value))
    (slot-boundp (slot-boundp obj 'slot-1))
    (slot-makunbound (slot-makunbound obj 'slot-1))
    (slot-value (slot-value obj 'slot-1))))
    (otherwise (call-next-method)))))


    This redirects or "forwards" slot-value operations on slot-3 and slot-2
    to slot-1.

    (setq $f (make-instance 'foo))
    (slot-value $f 'slot-1) ; 10
    (slot-value $f 'slot-2) ;10
    (setf (slot-value $f 'slot-3) 20) ;20

    I thought the only drawback is when slot-missing is signalled with the
    "setf" operation, that the spec specifies the setf operation doesn't
    return a value, but I think I misread it since it does
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From steve g@sgonedes1977@gmail.com to comp.lang.lisp on Tue Jun 2 21:50:18 2026
    From Newsgroup: comp.lang.lisp

    Madhu <enometh@meer.net> writes:


    Yes, I was able to replace all that slot-value-using-class machinery
    with slot-missing.

    (defclass foo ()
    ((slot-1 :initform 10 :initarg :slot-1)))

    (defmethod slot-missing ((class standard-class) (obj foo) slot operation
    &optional new-value)
    (let ((slot-name
    (etypecase slot
    (symbol slot)
    (ccl:standard-effective-slot-definition
    (ccl:slot-definition-name slot)))))
    (case slot-name
    (slot-2
    (ecase operation
    (setf (setf (slot-value obj 'slot-1) new-value))
    (slot-boundp (slot-boundp obj 'slot-1))
    (slot-makunbound (slot-makunbound obj 'slot-1))
    (slot-value (slot-value obj 'slot-1))))
    (slot-3
    (ecase operation
    (setf (setf (slot-value obj 'slot-1) new-value))
    (slot-boundp (slot-boundp obj 'slot-1))
    (slot-makunbound (slot-makunbound obj 'slot-1))
    (slot-value (slot-value obj 'slot-1))))
    (otherwise (call-next-method)))))


    This redirects or "forwards" slot-value operations on slot-3 and slot-2
    to slot-1.


    have you tried with-slots macro?

    https://www.lispworks.com/documentation/HyperSpec/Body/m_w_slts.htm
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Madhu@enometh@meer.net to comp.lang.lisp on Wed Jun 3 09:21:15 2026
    From Newsgroup: comp.lang.lisp


    * steve g <87eciocrz9.fsf@gmail.com> :
    Wrote on Tue, 02 Jun 2026 21:50:18 -0400:


    have you tried with-slots macro?

    https://www.lispworks.com/documentation/HyperSpec/Body/m_w_slts.htm

    yes, haven't checked but it's a "symbol macro" which expands to
    slot-value forms, it's the greatest thing because you can use SETQ
    instead of SETF.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From steve g@sgonedes1977@gmail.com to comp.lang.lisp on Wed Jun 3 22:48:01 2026
    From Newsgroup: comp.lang.lisp

    Madhu <enometh@meer.net> writes:

    slot-value forms, it's the greatest thing because you can use SETQ
    instead of SETF.


    agreed!
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Thu Jun 4 03:22:11 2026
    From Newsgroup: comp.lang.lisp

    On Wed, 03 Jun 2026 09:21:15 +0530, Madhu wrote:

    ... because you can use SETQ instead of SETF.

    CanrCOt you use setf for assigning to everything?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From steve g@sgonedes1977@gmail.com to comp.lang.lisp on Thu Jun 4 17:01:51 2026
    From Newsgroup: comp.lang.lisp

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:

    On Wed, 03 Jun 2026 09:21:15 +0530, Madhu wrote:

    < > ... because you can use SETQ instead of SETF.

    CanrCOt you use setf for assigning to everything?

    yes and no. setf if a fat macro, setq is preferable to set.

    check https://www.lispworks.com/documentation/HyperSpec/Body/f_set.htm

    setf = set field
    setq = set quote
    set = set



    ; SLIME 2.26.1
    CL-USER>
    ; No value
    CL-USER>
    ; No value
    CL-USER> (defvar xyz)
    XYZ
    CL-USER> (set 'xyz 123)
    123
    CL-USER> xyz
    123
    CL-USER> (setq xyz (make-array 10 :element-type 'symbol :initial-element nil)) #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)
    CL-USER> xyz
    #(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)
    CL-USER> (setf (aref 0 xyz 3) 'three)
    ; Evaluation aborted on #<TYPE-ERROR expected-type: ARRAY datum: 0>.
    CL-USER> (setf (aref xyz 3) 'three)
    THREE
    CL-USER> (loop for i downfrom (1- (length xyz)) to 0
    do (setf (aref xyz i) t))
    NIL
    CL-USER> xyz
    #(T T T T T T T T T T)
    CL-USER> (setq (aref xyz 2) nil)
    ; Evaluation aborted on #<TYPE-ERROR expected-type: SYMBOL datum: (AREF XYZ 2)>.
    CL-USER>
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Thu Jun 4 22:42:04 2026
    From Newsgroup: comp.lang.lisp

    On Thu, 04 Jun 2026 17:01:51 -0400, steve g wrote:

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:

    CanrCOt you use setf for assigning to everything?

    yes and no. setf if a fat macro, setq is preferable to set.

    Why rCLpreferablerCY? Seems to me you have less to worry about in terms of special cases if you just use setf.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From tfb@no_email@invalid.invalid to comp.lang.lisp on Sun Jun 7 16:31:10 2026
    From Newsgroup: comp.lang.lisp

    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/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From tfb@no_email@invalid.invalid to comp.lang.lisp on Sun Jun 7 16:42:19 2026
    From Newsgroup: comp.lang.lisp

    Lawrence D-|Oliveiro <ldo@nz.invalid> wrote:

    CanrCOt 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/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.lisp on Sun Jun 7 12:31:27 2026
    From Newsgroup: comp.lang.lisp

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Madhu@enometh@meer.net to comp.lang.lisp on Mon Jun 8 04:06:09 2026
    From Newsgroup: comp.lang.lisp

    * 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)
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Madhu@enometh@meer.net to comp.lang.lisp on Mon Jun 8 04:13:55 2026
    From Newsgroup: comp.lang.lisp

    * Lawrence DrCOOliveiro <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 rCLpreferablerCY? 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







    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Sun Jun 7 23:22:02 2026
    From Newsgroup: comp.lang.lisp

    On Mon, 08 Jun 2026 04:13:55 +0530, Madhu wrote:

    On Thu, 4 Jun 2026 22:42:04 -0000 (UTC), Lawrence DrCOOliveiro wrote:

    yes and no. setf if a fat macro, setq is preferable to set.

    Why rCLpreferablerCY? Seems to me you have less to worry about in terms
    of special cases if you just use setf.

    using SETQ signals that there is nothing complicated going on under
    the surface syntax.

    I see ... so itrCOs rCLpreferablerCY in the sense that it forbids certain levels of underlying abstraction from being applicable in this
    situation?

    EXCEPT IN SYMBOL-MACROLET where it is defined to
    work as SETF, which is the context in which I made the **** comment

    ... except in such a case, when it *doesnrCOt* forbid those certain
    levels of underlying abstraction from being applicable in that
    situation?

    Is it still rCLpreferablerCY in that situation?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Sun Jun 7 23:24:08 2026
    From Newsgroup: comp.lang.lisp

    On Sun, 7 Jun 2026 16:42:19 -0000 (UTC), tfb wrote:

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

    :)
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Nuno Silva@nunojsilva@invalid.invalid to comp.lang.lisp on Mon Jun 8 00:57:43 2026
    From Newsgroup: comp.lang.lisp

    On 2026-06-08, Lawrence DrCOOliveiro 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
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Mon Jun 8 02:27:52 2026
    From Newsgroup: comp.lang.lisp

    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 ...
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From tfb@no_email@invalid.invalid to comp.lang.lisp on Mon Jun 8 07:36:52 2026
    From Newsgroup: comp.lang.lisp

    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/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From tfb@no_email@invalid.invalid to comp.lang.lisp on Mon Jun 8 07:52:17 2026
    From Newsgroup: comp.lang.lisp

    Lawrence D-|Oliveiro <ldo@nz.invalid> wrote:

    ... except in such a case, when it *doesnrCOt* forbid those certain
    levels of underlying abstraction from being applicable in that
    situation?

    Or in any other case where the thing you think is a variable is a binding established by some form, which may, behind the scenes, use a symbol macro instead, or *sometimes* use a symbol macro. It probably is the case that
    LET itself is not allowed to do that (so variables actually exist). As an example of this my SITH-SHORTHANDS macro will cause its bindings to be variables if you've used the read-once option, otherwise they'll be symbol macros. Or may be it is more complicated than that: I forget.

    I mean, on the assumption that LET, LAMBDA etc are not allowed to use
    symbol macros (I think they are probably not, but I'm not sure if the spec really says that) then the *only* place SETQ would be 'preferable' is where
    the variable is bound by one of those forms.


    Is it still rCLpreferablerCY in that situation?


    It's never preferable...
    --
    www.tfeb.org/computer/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Stefan Monnier@monnier@iro.umontreal.ca to comp.lang.lisp on Mon Jun 8 09:25:30 2026
    From Newsgroup: comp.lang.lisp

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

    EfOa


    === Stefan
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Tue Jun 9 00:30:24 2026
    From Newsgroup: comp.lang.lisp

    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?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From steve g@sgonedes1977@gmail.com to comp.lang.lisp on Tue Jun 9 00:25:34 2026
    From Newsgroup: comp.lang.lisp

    Lawrence DrCOOliveiro <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...
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From tfb@no_email@invalid.invalid to comp.lang.lisp on Tue Jun 9 05:49:26 2026
    From Newsgroup: comp.lang.lisp

    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/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.lisp on Sat Jun 13 12:41:35 2026
    From Newsgroup: comp.lang.lisp

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    I see ... so itrCOs rCLpreferablerCY in the sense that it forbids certain levels of underlying abstraction from being applicable in this
    situation?

    Sort of like a type annotation, I guess.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Sun Jun 14 01:04:42 2026
    From Newsgroup: comp.lang.lisp

    On Sat, 13 Jun 2026 12:41:35 -0700, Paul Rubin wrote:

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:

    I see ... so [setq is] rCLpreferablerCY in the sense that it forbids
    certain levels of underlying abstraction from being applicable in
    this situation?

    Sort of like a type annotation, I guess.

    New to type annotations?

    Type annotations are supposed to be declarative. You typically write
    them once at the point of introduction of the variable, not repeated
    everywhere you are trying to assign to it.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.lisp on Sun Jun 14 01:48:46 2026
    From Newsgroup: comp.lang.lisp

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    Type annotations are supposed to be declarative. You typically write
    them once at the point of introduction of the variable, not repeated everywhere you are trying to assign to it.

    Lisp isn't Python.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Sun Jun 14 23:52:25 2026
    From Newsgroup: comp.lang.lisp

    On Sun, 14 Jun 2026 01:48:46 -0700, Paul Rubin wrote:

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:

    Type annotations are supposed to be declarative. You typically
    write them once at the point of introduction of the variable, not
    repeated everywhere you are trying to assign to it.

    Lisp isn't Python.

    You really think Python invented type annotations?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.lisp on Sun Jun 14 17:31:40 2026
    From Newsgroup: comp.lang.lisp

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    You really think Python invented type annotations?

    Python has them in a particular style, other languages use different
    styles. In Haskell you can put them pretty much anywhere. CL is also different.

    You could also view setq as having a particular type signature, sort of
    like Haskell's "length" function (which returns an Int, Haskell's type
    for machine-sized ints). Haskell also has "genericLength" which is polymorphic, sort of like setf vs setq. It's idiomatic in Haskell to
    use "length" most of the time. You'd use genericLength if, e.g., you
    were doing bignum arithmetic with result.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Nuno Silva@nunojsilva@invalid.invalid to comp.lang.lisp on Mon Jun 15 10:22:33 2026
    From Newsgroup: comp.lang.lisp

    On 2026-06-08, Stefan Monnier wrote:

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

    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
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Tue Jun 16 00:14:33 2026
    From Newsgroup: comp.lang.lisp

    On Sun, 14 Jun 2026 17:31:40 -0700, Paul Rubin wrote:

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:
    .
    You really think Python invented type annotations?

    Python has them in a particular style, other languages use different
    styles.

    One thing they all have in common is that they are declarative. They
    are parts of the declarations of things, not the uses of them.

    In Haskell you can put them pretty much anywhere.

    Haskell is a functional language. It has no rCLsetqrCY.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From steve g@Sgonedes1977@gmail.com to comp.lang.lisp on Fri Jun 19 22:00:35 2026
    From Newsgroup: comp.lang.lisp

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From steve g@Sgonedes1977@gmail.com to comp.lang.lisp on Fri Jun 19 22:04:55 2026
    From Newsgroup: comp.lang.lisp

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:

    On Thu, 04 Jun 2026 17:01:51 -0400, steve g wrote:

    Lawrence DrCOOliveiro <ldo@nz.invalid> writes:

    CanrCOt you use setf for assigning to everything?

    yes and no. setf if a fat macro, setq is preferable to set.

    Why rCLpreferablerCY? 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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From steve g@Sgonedes1977@gmail.com to comp.lang.lisp on Fri Jun 19 22:05:41 2026
    From Newsgroup: comp.lang.lisp

    Madhu <enometh@meer.net> writes:

    * Lawrence DrCOOliveiro <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 rCLpreferablerCY? 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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From steve g@Sgonedes1977@gmail.com to comp.lang.lisp on Fri Jun 19 23:10:02 2026
    From Newsgroup: comp.lang.lisp

    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>
    --- Synchronet 3.22a-Linux NewsLink 1.2