Re: type specifier '(simple-vector n) in defmethod
Tim McNerney <[email protected]> Fri, 5 Jan 2024 08:41:09 -0500
| Newsgroups | gmane.lisp.openmcl.devel |
|---|---|
| Message-ID | <[email protected]> |
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 > >