Why is `+' a method and not a generic function? 
Author Message
 Why is `+' a method and not a generic function?

Page 149 of the Dylan book states

        + and * are methods so you can't add other methods to them.
        To extend the protocols, add methods to binary+ and binary*.

Are + and * methods and not generic functions solely so other methods
can't be added to them?

As I work on a Dylan implementation with a C core and a Dylan runtime,
I'm struck by the fact there is no good way of constructing such a
method without it being anonymous (a pain from a debugging and error
reporting point of view):

        ? (define + (method (#rest numbers) (reduce binary+ 0 numbers)))
        ? (+ 3 4 5)
        12
        ? +
        {an anonymous method}

Why not make + and * read-only generic functions?

? (define-method + (#rest numbers)
    (reduce binary+ 0 numbers))
? (make-read-only +)
{the generic function +}

Why not define methods as instantiable with a debug-name: keyword?

(define + (make <method> debug-name: '+
                         method: (method (#rest numbers)
                                   (reduce binary+ 0 numbers))))
--
Brent Benson
Harris Computer Systems



Fri, 22 Dec 1995 03:44:27 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Why is `+' a method and not a generic function?

2. Why is '+' a method and not a generic function?

3. @U$`')-`:023/7H

4. Distributed objects vs. generic functions and multi-methods

5. Distributed objects vs. generic functions and multi-methods

6. ENSURE-GENERIC-FUNCTION and method combinations?

7. Generic Functions vs. CLOS Methods

8. Inspecting the methods associated to a generic function

9. Why I am not enthusiatic about OO COBOL

10. Why I am not reaching callbacks ?

11. 'bind' functions into methods

12. 'capwords' is not a string method

 

 
Powered by phpBB® Forum Software