[plt-scheme] polymorphism of primitive types

From: Yoav Goldberg (yoav.goldberg at gmail.com)
Date: Tue Oct 18 08:56:05 EDT 2005

> Let me comment however on the need to co-mingle lists and streams.
> It is quite uncommon that the same program fragments need to process
> both lists and streams in the same program. If you believe you have
> a design that requires just that, please share with us.

What I had in mind was something in the lines of:

(define qqh (list->infinite-stream '(quarter quarter half))
(map (lambda (pitch duration) (make-sound 'pitch: pitch 'duration: duration)
        (list DO RE MI FA SO LA SI)

but after some thinking I realized it can probably be turned into a
stream-only implementation by wrapping map to do list->stream on all
the list arguments.
(I will probably also need to redefine "apply" to do a stream->list on
it's arguments).

But, let's say I'm willing to stick to just a few selected sequence
types, forget about ease of extensibility to more sequence types, and
am willing to implement all the desired functions (say
car,cdr,null?,map,append,length) for each of the types I plan to
support, and will write my own primitive type-based dispatcher.

I really want to stay with the traditional names, though.

Can I have a module provide car, cdr etc without making it a new language?
(I can see how redefining some of the primitive functions can be
considered as a new language, and otoh I can also see how it is not).


Posted on the users mailing list.