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-08 04:06 +0530
Articles 20 on this page of 33 — 7 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 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

Page 1 of 2  [1] 2  Next page →


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

FromMadhu <enometh@meer.net>
Date2026-04-25 20:35 +0530
Subjectslot-value-using-class to remap "virtual" slots & closer-mop
Message-ID<m3ldebnkqu.fsf@pison.robolove.meer.net>
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.

[toc] | [next] | [standalone]


#60778

Fromtfb <no_email@invalid.invalid>
Date2026-04-25 18:27 +0000
Message-ID<10sj12c$11lo5$1@dont-email.me>
In reply to#60777
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/

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


#60787

FromMadhu <enometh@meer.net>
Date2026-05-07 05:22 +0530
Message-ID<m37bpg14fm.fsf@pison.robolove.meer.net>
In reply to#60777
* 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.

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


#60788

FromStefan Monnier <monnier@iro.umontreal.ca>
Date2026-05-07 15:14 -0400
Message-ID<jwvcxz7doj6.fsf-monnier+comp.lang.lisp@gnu.org>
In reply to#60787
> 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

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


#60789

FromMadhu <enometh@meer.net>
Date2026-05-08 09:48 +0530
Message-ID<m3wlxezg7l.fsf@pison.robolove.meer.net>
In reply to#60788
* 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

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


#60799

Fromsteve g <sgonedes1977@gmail.com>
Date2026-06-02 21:50 -0400
Message-ID<87eciocrz9.fsf@gmail.com>
In reply to#60789
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

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


#60801

FromMadhu <enometh@meer.net>
Date2026-06-03 09:21 +0530
Message-ID<m3o6hscmdo.fsf@pison.robolove.meer.net>
In reply to#60799
* 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.

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


#60802

Fromsteve g <sgonedes1977@gmail.com>
Date2026-06-03 22:48 -0400
Message-ID<87cxy7vx5q.fsf@gmail.com>
In reply to#60801
Madhu <enometh@meer.net> writes:

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


agreed!

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


#60803

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-04 03:22 +0000
Message-ID<10vqr13$4jdd$1@dont-email.me>
In reply to#60801
On Wed, 03 Jun 2026 09:21:15 +0530, Madhu wrote:

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

Can’t you use setf for assigning to everything?

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


#60804

Fromsteve g <sgonedes1977@gmail.com>
Date2026-06-04 17:01 -0400
Message-ID<87se72xbnk.fsf@gmail.com>
In reply to#60803
Lawrence D’Oliveiro <ldo@nz.invalid> writes:

> On Wed, 03 Jun 2026 09:21:15 +0530, Madhu wrote:
>
< > ... because you can use SETQ instead of SETF.
>
> Can’t 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>

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


#60805

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-04 22:42 +0000
Message-ID<10vsuvs$nejc$4@dont-email.me>
In reply to#60804
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.

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


#60811

FromMadhu <enometh@meer.net>
Date2026-06-08 04:13 +0530
Message-ID<m3pl220y50.fsf@pison.robolove.meer.net>
In reply to#60805
* 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






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


#60812

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-07 23:22 +0000
Message-ID<1104ueq$2rlf4$4@dont-email.me>
In reply to#60811
On Mon, 08 Jun 2026 04:13:55 +0530, Madhu wrote:

> On Thu, 4 Jun 2026 22:42:04 -0000 (UTC), Lawrence D’Oliveiro wrote:
>>
>>> 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.
>
> using SETQ signals that there is nothing complicated going on under
> the surface syntax.

I see ... so it’s “preferable” 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 *doesn’t* forbid those certain
levels of underlying abstraction from being applicable in that
situation?

Is it still “preferable” in that situation?

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


#60817

Fromtfb <no_email@invalid.invalid>
Date2026-06-08 07:52 +0000
Message-ID<1105sbh$32ieu$1@dont-email.me>
In reply to#60812
Lawrence D´Oliveiro <ldo@nz.invalid> wrote:
>
> ... except in such a case, when it *doesn’t* 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 “preferable” in that situation?
>

It's never preferable...


-- 
www.tfeb.org/computer/

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


#60872

FromPaul Rubin <no.email@nospam.invalid>
Date2026-06-13 12:41 -0700
Message-ID<87y0gi8byo.fsf@nightsong.com>
In reply to#60812
Lawrence D’Oliveiro <ldo@nz.invalid> writes:
> I see ... so it’s “preferable” 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.

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


#60883

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-14 01:04 +0000
Message-ID<110kuna$3a32m$6@dont-email.me>
In reply to#60872
On Sat, 13 Jun 2026 12:41:35 -0700, Paul Rubin wrote:

> Lawrence D’Oliveiro <ldo@nz.invalid> writes:
>>
>> I see ... so [setq is] “preferable” 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.

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


#60892

FromPaul Rubin <no.email@nospam.invalid>
Date2026-06-14 01:48 -0700
Message-ID<87fr2p7bip.fsf@nightsong.com>
In reply to#60883
Lawrence D’Oliveiro <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.

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


#60895

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-14 23:52 +0000
Message-ID<110nerp$3vra6$2@dont-email.me>
In reply to#60892
On Sun, 14 Jun 2026 01:48:46 -0700, Paul Rubin wrote:

> Lawrence D’Oliveiro <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?

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


#60897

FromPaul Rubin <no.email@nospam.invalid>
Date2026-06-14 17:31 -0700
Message-ID<8733yo7ifn.fsf@nightsong.com>
In reply to#60895
Lawrence D’Oliveiro <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.

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


#60911

FromLawrence D’Oliveiro <ldo@nz.invalid>
Date2026-06-16 00:14 +0000
Message-ID<110q4h9$o45a$5@dont-email.me>
In reply to#60897
On Sun, 14 Jun 2026 17:31:40 -0700, Paul Rubin wrote:

> Lawrence D’Oliveiro <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 “setq”.

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


Page 1 of 2  [1] 2  Next page →

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


csiph-web