Path: utzoo!attcan!uunet!snorkelwacker!ai-lab!zurich.ai.mit.edu!markf From: markf@zurich.ai.mit.edu (Mark Friedman) Newsgroups: comp.lang.scheme Subject: Re: Scheme is unnecessarily biased towards lists Message-ID: Date: 20 Sep 90 14:56:27 GMT References: <9009200822.AA02949@vis.> Sender: news@ai.mit.edu Reply-To: markf@zurich.ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 56 In-reply-to: greg@vis.UUCP's message of 20 Sep 90 08:22:19 GMT In article <9009200822.AA02949@vis.> greg@vis.UUCP writes: [Scheme] should replace the generic arithmetic operators with type-specific ones and provide a generic dispatch mechanism (e.g., OO messaging system) to solve the general problem. BTW, has anyone else find that Scheme's generic operators actually make adding new numeric types more difficult? What is difficult or not general about the following: (set! + (lambda addends (if (my-new-numeric-types? addends) (apply my-new-numeric-type+ addends) (apply + addends)))) With macros you could abstract the mechanism with something like: (define-macro (add-new-numeric-type type-name) (let ((symbol-append (lambda (sym1 sym2) (string->symbol (string-append (symbol->string sym1) (symbol->string sym2)))))) (let ((type-predicate-name (symbol-append type-name '?)) (addition-proc-name (symbol-append type-name '+)) (multiplication-proc-name (symbol-append type-name '*)) ...) `(begin (set! + (lambda addends (if (,type-predicate-name addends) (apply ,addition-proc-name addends) (apply + addends)))) (set! * ...) ...)))) He (greg@vis.UUCP) also writes: I've always wondered why vectors are not on a more equal footing with lists. It seems like pure prejudice to me. Why is (+ 2 2) O.K. but #(+ 2 2) is not? They are both O.K. It happens that most interpretors use an evaluator that treats a list as denoting a combination and applies the car of the list to the cdr. It doesn't have to be this way and I don't think that there is anything in the scheme standards that legislates this behavior. -Mark -- Mark Friedman MIT Artificial Intelligence Lab 545 Technology Sq. Cambridge, Ma. 02139 markf@zurich.ai.mit.edu