[plt-scheme] polymorphism of primitive types

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

> > 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..
> I suppose one could make a module "empty" that contains nothing
> but #%module-begin and #%require. And also
>   mymzscheme.ss      mzscheme without arithmetic and list operations
>   list.ss            mzscheme list operations
>   arithmetic.ss      mzscheme arithmetic
> [...]

This is possible, but I don't consider it as a real solution. Two
problems that come to mind are:

1/ What if different people want to override different sets of
operations, and make them available as modules? The "mymzscheme.ss" is
no longer "my"...

2/ the thing with modules is that you can have many of them, and
always use a small subset them. Let's say I have, err, 10 different
modules, each overriding some subset of the default mzscheme
primitives. Now let's say I want to use two of them. In this case,
I'll have to start my programs with:
(module my-prog mymzscheme
   (require "my-arith.ss" "my-seq.ss"
   <8 more requires that I need in order to get myself to full power of scheme>)
...)



When using "require" outside of a module, the bindings provided by the
required module override those in the global namespace.
This works just fine:
(module override-car
   (provide car)
   (define car 'something-else))
(require override-car)


But inside a module, things works differently:
(module m mzscheme
   (require override-car) ) ;; this fails.

Why is this distinction?


Posted on the users mailing list.