Re: type specifier '(simple-vector n) in defmethod
Michał "phoe" Herda <[email protected]> Fri, 5 Jan 2024 14:44:20 +0100
| Newsgroups | gmane.lisp.openmcl.devel |
|---|---|
| Message-ID | <[email protected]> |
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 >> >> >