[Openmcl-devel] type specifier '(simple-vector n) in defmethod

Michał "phoe" Herda phoe at disroot.org
Fri Jan 5 05:44:20 PST 2024


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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20240105/1bdc125f/attachment.htm>


More information about the Openmcl-devel mailing list