Hi
I created a Google form to vote on the name...
Cheers
Marco
Begin forwarded message:
From: marcoxa@gmail.com Date: February 16, 2011 9:58:50 AM GMT+01:00 To: marcoxa@cs.nyu.edu Subject: Names for the equality generic function
If you have trouble viewing or submitting this form, you can fill it out online: https://spreadsheets.google.com/viewform?formkey=dDFZSTJ4OTlCTlNaQlc3YlhUNjA...
-- Marco Antoniotti
In case the previous link does not work, try this other one.
https://spreadsheets.google.com/ccc?key=0AiVeTqcPbn1sdDFZSTJ4OTlCTlNaQlc3Ylh...
Marco
On Feb 16, 2011, at 10:02 , Marco Antoniotti wrote:
Hi
I created a Google form to vote on the name...
Cheers
Marco
Begin forwarded message:
From: marcoxa@gmail.com Date: February 16, 2011 9:58:50 AM GMT+01:00 To: marcoxa@cs.nyu.edu Subject: Names for the equality generic function
If you have trouble viewing or submitting this form, you can fill it out online: https://spreadsheets.google.com/viewform?formkey=dDFZSTJ4OTlCTlNaQlc3YlhUNjA...
• • • • • • • • •
-- Marco Antoniotti
cdr-discuss mailing list cdr-discuss@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cdr-discuss
-- Marco Antoniotti
Marco Antoniotti marcoxa@cs.nyu.edu writes:
Hi
I created a Google form to vote on the name...
Cheers
Marco
Begin forwarded message:
From: marcoxa@gmail.com Date: February 16, 2011 9:58:50 AM GMT+01:00 To: marcoxa@cs.nyu.edu Subject: Names for the equality generic function If you have trouble viewing or submitting this form, you can fill it out online: https://spreadsheets.google.com/viewform?formkey=dDFZSTJ4OTlCTlNaQlc3YlhUNjAza1E6MQ Names for the equality generic function What name should be used for the generic function "equality"? * □ ( ) EQUALITY □ ( ) EQUIV □ ( ) EQUP □ ( ) EQUALS □ ( ) == □ ( ) EQUIVALENT □ ( ) AEQUALIS □ ( ) SAMEP □ ( ) EQUIVP
I voted for EQUALS. It should be in length at least more than EQUAL. EQUAL shows that it doesn't necessarily needs the -P postfix.
EQUALS being of same length as EQUALP shows that
(equals x y) <= (equalp x y)
doesn't need to hold.
On the other hand, we should have:
(equals x y) <= (equal x y)
AEQUALIS was nice, but let's keep CL English.
I definitely reject EQUIVALENT and similar, because equivalence is a different notion n what I think is wanted with this equality generic function.
I have an alternative to coming up with different names for the generic equivalent to Common Lisp functions:
Give the generic functions the same name as the equivalent Common Lisp functions and intern them in a new package that doesn't use the CL package.
Actually, I'd like to see generic equivalents for many Common Lisp functions beyond equality. Using a different package but the same names for the methods as for the Common Lisp functions would save us from coming up with new names - and from having to remember the new names when coding.
Say the new package for generic Common Lisp functions has a nickname GL for short. Then the generic for equality would be GL:EQUALP.
A GL package could initially implement the basic equivalent methods for Common Lisp functions simply by calling the Common Lisp function, such as:
(defmethod gl:equalp (object1 object2) (cl:equalp object1 object2))
Developers can then specialize these methods for custom classes and datatypes. Not only gl:equalp, but also gl:mapcar, gl:sort, gl:rest, ...
-- Terje Norderhaug
Marco Antoniotti marcoxa@cs.nyu.edu
From: marcoxa@gmail.com Date: February 16, 2011 9:58:50 AM GMT+01:00 To: marcoxa@cs.nyu.edu Subject: Names for the equality generic function
If you have trouble viewing or submitting this form, you can fill it out online: https://spreadsheets.google.com/viewform?formkey=dDFZSTJ4OTlCTlNaQlc3YlhUNjA...
Names for the equality generic function
What name should be used for the generic function "equality"? * □ ( ) EQUALITY □ ( ) EQUIV □ ( ) EQUP □ ( ) EQUALS □ ( ) == □ ( ) EQUIVALENT □ ( ) AEQUALIS □ ( ) SAMEP □ ( ) EQUIVP
Terje Norderhaug terje@in-progress.com writes:
I have an alternative to coming up with different names for the generic equivalent to Common Lisp functions:
Give the generic functions the same name as the equivalent Common Lisp functions and intern them in a new package that doesn't use the CL package.
Well, here's yet another alternative: trampoline the Common Lisp functions to generic functions of the same name in a new package that doesn't use Common Lisp. (This is what I have done with the sequence functions, to reasonable success).
Not that I think that a normal generic function for EQUAL/EQUALP (or whatever you want to call it) is in any way a good idea; it is a perfect example of a context-sensitive function, and modelling that with standard generic functions does not automate the inclusion of context.
Christophe
On 17 Feb 2011, at 10:14, Christophe Rhodes wrote:
Terje Norderhaug terje@in-progress.com writes:
I have an alternative to coming up with different names for the generic equivalent to Common Lisp functions:
Give the generic functions the same name as the equivalent Common Lisp functions and intern them in a new package that doesn't use the CL package.
Well, here's yet another alternative: trampoline the Common Lisp functions to generic functions of the same name in a new package that doesn't use Common Lisp. (This is what I have done with the sequence functions, to reasonable success).
Not that I think that a normal generic function for EQUAL/EQUALP (or whatever you want to call it) is in any way a good idea; it is a perfect example of a context-sensitive function, and modelling that with standard generic functions does not automate the inclusion of context.
Once it's a generic function, turning it into a context-sensitive function is not so hard anymore:
(defmethod equalp ((o1 my-class) (o2 my-class)) (case *my-context* (do ...) (di ...) (da ...) (otherwise ... default ...)))
...or with ContextL:
(define-layered-function my-equalp (o1 o2) (:method :in do (...) ...) (:method :in di (...) ...) (:method :in da (...) ...) (:method (...) ... default ...))
(defmethod equalp ((o1 my-class) (o2 my-class)) (my-equalp o1 o2))
The generic function equalp ensures that your own comparison methods are more easily available to other third-party code, and that's the main purpose of making it generic.
(If an existing function gets genericized, my vote would be for equalp, because I think equal still has good uses as a primitive comparison function, whereas I'm not so convinced of the utility of equalp.)
Pascal
Pascal Costanza pc@p-cos.net writes:
Once it's a generic function, turning it into a context-sensitive function is not so hard anymore:
(defmethod equalp ((o1 my-class) (o2 my-class)) (case *my-context* (do ...) (di ...) (da ...) (otherwise ... default ...)))
...or with ContextL:
(define-layered-function my-equalp (o1 o2) (:method :in do (...) ...) (:method :in di (...) ...) (:method :in da (...) ...) (:method (...) ... default ...))
(defmethod equalp ((o1 my-class) (o2 my-class)) (my-equalp o1 o2))
The generic function equalp ensures that your own comparison methods are more easily available to other third-party code, and that's the main purpose of making it generic.
That would be true if equalp only had one argument. Since it has two, the way in which it is made context-sensitive must be common between classes potentially "owned" by different codebases, otherwise extensions / specializations won't compose.
Cheers,
Christophe