Python syntax in Lisp and Scheme

Christopher C. Stacy cstacy at dtpq.com
Wed Oct 8 17:26:57 EDT 2003


>>>>> On 08 Oct 2003 11:47:45 -0700, Thomas F Burdick ("Thomas") writes:
 Thomas> How could you have both noncongruent argument lists, and multiple
 Thomas> dispatch?  With an either/or like that, Lisp chose the right one.

This reason that Common Lisp made this choice is not because non-congruent
multiple-dispatch methods are impossible. To dispatch: instead of just
matching the types of the args, consider only those handler entries that
have the correct shape (length) as well.

JAVA has multi-methods with non-congruent arglist.
(It doesn't have multiple inheritence, but that doesn't 
matter to dynamic type dispatching, except maybe in how 
you implement searching your handler tables.)  In JAVA, 
the correspondance of the "signature" of the function call
and the method definition are what's important;
and there are no restricting "generic functions".

public class RandomAccessFile extends Object,implements DataOutput {
  public void write(byte[] b) throws IOException;
  public void write(byte[] b, int off, int len) throws IOException;
  ...
}

CLOS imposes an aesthetic design restriction on the programmer:
methods with the same name should be conceptually doing the
same function, and therefore should be all taking the same args.
The generic function is the documentation of that mono protocol.
This is one of the few places that Lisp takes a facist attitude.




More information about the Python-list mailing list