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

Tim McNerney mc at media.mit.edu
Fri Jan 5 05:41:09 PST 2024


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/90cea2fd/attachment.htm>


More information about the Openmcl-devel mailing list