From: Joel Ray Holveck
Subject: Method selection: are vectors sequences or arrays first?
Date: 
Message-ID: <y7cbsbnxaqr.fsf@sindri.juniper.net>
I was playing around with a generic function that includes a method
for sequence, and another for array, ie:

(defmethod my-func ((obj sequence))
  (do-this obj))
(defmethod my-func ((obj array))
  (do-something-else obj))

Does Common Lisp guarantee which one will be called?

From the spec, section 7.6.6.1.2 (Sorting the Applicable Methods by
Precedence Order), it says it should do this by class precedence list.
However, the section "System Class VECTOR" does not indicate what the
class precedence list is.  (Indeed, it doesn't mention that VECTOR is
a subtype of SEQUENCE.)  From a reading of the spec (references
available on request) it seems that what I am doing is perfectly
legal, but I can't find anything to tell me what it does.

Do I have a guarantee here?

Thanks,
joelh

From: Joe Marshall
Subject: Re: Method selection: are vectors sequences or arrays first?
Date: 
Message-ID: <qG6D8.11035$sg2.1873733@typhoon.ne.ipsvc.net>
"Joel Ray Holveck" <·····@juniper.net> wrote in message ····················@sindri.juniper.net...
> I was playing around with a generic function that includes a method
> for sequence, and another for array, ie:
>
> (defmethod my-func ((obj sequence))
>   (do-this obj))
> (defmethod my-func ((obj array))
>   (do-something-else obj))
>
> Does Common Lisp guarantee which one will be called?
>
> From the spec, section 7.6.6.1.2 (Sorting the Applicable Methods by
> Precedence Order), it says it should do this by class precedence list.
> However, the section "System Class VECTOR" does not indicate what the
> class precedence list is.

You need a new spec.  The Hyperspec says in section 15.2.3 that the
class precedence list for system class vector is

vector, array, sequence, t

>
> Do I have a guarantee here?
>

I guarantee that my copy of the Hyperspec says that.  I'll even back you
up in a flame war.  Whether your particular Lisp implementation does it
right is another thing.
From: Joel Ray Holveck
Subject: Re: Method selection: are vectors sequences or arrays first?
Date: 
Message-ID: <y7c1ycipelw.fsf@sindri.juniper.net>
>> I was playing around with a generic function that includes a method
>>  for sequence, and another for array, ie:
[snip]
> You need a new spec.  The Hyperspec says in section 15.2.3 that the
> class precedence list for system class vector is
> vector, array, sequence, t

I don't need a new spec, just a new set of eyes.  Boy, is my face red!

>> Do I have a guarantee here?
> I guarantee that my copy of the Hyperspec says that.  I'll even back you
> up in a flame war.  Whether your particular Lisp implementation does it
> right is another thing.

A good point, but I think I'll be happy with this much until I find a
Lisp implementation that does it wrong.

Thanks for the help,
joelh