[plt-scheme] polymorphism of primitive types

From: Yoav Goldberg (yoav.goldberg at gmail.com)
Date: Tue Oct 18 10:29:48 EDT 2005

> > 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)
> >         qqh)
> I believe that you don't want infinite lists but rationale ones, i.e.,
> lists with repeated patterns. These are graphs and you should probably
> just turn them into graphs:
> (define qqh (shared ([qqh (cons quarter (cons quarter (cons half
> qqh)))]) qqh))
> Have you considered that?

I didn't know about this option. Thanks. I'll consider it. Where's the
best place to read about it?

> [...]
> Don't confuse using a module as a language vs making a drscheme
> language.
> The former is almost no effort; the latter requires more work.

The problem I have with using a module as a new language is that you
can only have one of these.
Let's say I want to reimplement both sequence operations (cons, car,
cdr..) and arithmetics (+,-,..).
At some of my programs I would like to have only the new sequence
operations, on others only the new arithmetics, and on some of them I
would like to have both.
When using module as modules, this can be easily done:
(module my-prog1 mzscheme
  (require "my-seq.ss")
  ..)
(module my-prog2 mzscheme
  (require "my-arith.ss")
  (require "my-seq.ss")
  ..)

but when using modules as language, I would have to create a new language
for every combination I want to use..


Yoav


Posted on the users mailing list.