Re: type specifier '(simple-vector n) in defmethod
Tim McNerney <[email protected]> Fri, 5 Jan 2024 09:46:00 -0500
| Newsgroups | gmane.lisp.openmcl.devel |
|---|---|
| Message-ID | <[email protected]> |
Thanks for the support, Phoe. From the technological context of early CL history, I do sort-of "get" some of the thinking behind method dispatch limitations. (Too bad Gregor isn't here to speak for himself). At the time, Common Lisp proponents were deathly afraid of Lisp's reputation as a "slow language," so it is unclear that CL being originally designed in the /absence/ of CLOS is to blame. I suppose it is interesting that, at least in my circles, performance declarations never caught on (e.g. speed 3, safety 0). In my professional work, I have been known to seek out and destroy such monsters in every library we use. --Tim On 1/5/24 8:44 AM, Michał "phoe" Herda wrote: > > I'm not arguing that it shouldn't be in CL, I'm arguing that it's not > there because no one has done it. I guess you're free to extend CCL > with the functionality you're proposing, i.e. by introducing a new > method specializer in addition to the current class and EQL > specialization. > > Once a single working implementation is there, it's much easier to > convince other implementations to add it and end up turning it into a > de-facto standard (like with package-local nicknames). > > On 5.01.2024 14:41, Tim McNerney wrote: >> To which, (at the risk of a civilized flame war), I say, "too bad." >> IMHO, this was a short-sighted and poor design decision by the X3J13 >> committee, /et al/. >> The same debate came up within the greater Java community, >> and it is one place where Java and C# diverged. >> Java's designers made similar choices to Common Lisp's: >> two kinds of datatypes, dispatchable objects and everything else. >> C# is arguably "Java done right," where /everything/ is a >> dispatchable "object." >> >> There are clear benefits: it would also result in a cleaner, more >> appealing, more powerful language. >> It's not too late to fix this flaw. What's the harm? >> The "non-object" dispatch code would only be present in generic >> functions when necessary. >> >> --Tim >> >> On 1/2/24 6:17 AM, Michał "phoe" Herda wrote: >>> >>> No, standard CLOS dispatch happens only on classes. >>> >>> Have you tried https://github.com/digikar99/polymorphic-functions ? >>> >>> W dniu 2024-01-02 12:14, Taoufik Dachraoui napisał(a): >>> >>>> Hi >>>> I am trying to use '(simple-vector n) as type specifier in >>>> defmethod but it is not possible, is there another way? >>>> >>>> (typep #(1 2 3 4) '(simple-vector 4)) >>>> >>>> (defmethod mul ((n fixnum) (m1 (simple-vector n)) (m2 >>>> (simple-vector n))) >>>> (let ((r (make-array (list n)))) >>>> (dotimes (i n) >>>> (setf (svref r i) (* (svref m1 i) (svref m2 i)))) >>>> r)) >>>> Kind regards >>>> Taoufik Dachraoui >>> >>> >>