[plt-scheme] polymorphism of primitive types

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Tue Oct 18 09:14:37 EDT 2005

Yoav Goldberg wrote:

> 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).

If you squint, it is difficult to see the difference between requiring
a module and changing the language. In order words, don't be afraid do
something like this:

;;; mylist.ss
(module mylist mzscheme
   (provide (rename cons mycons)
            (rename car  mycar))
   (define mycons ...)
   (define mycar ...))
)

;;; mymzscheme.ss
(module mymzscheme mzscheme
   (require (prefix my: "mylist.ss"))
   (provide (all-from-except mzscheme cons car ...)
            (rename cons my:cons)
            (rename car  my:car)
            ...)

And then start all your modules with:

;;; foo.ss
(module foo "mymzscheme.ss"
    ...)

An alternative is to use a sequence datastructure that
behaves both like a list and a vector, for example
random access lists. I have attached list.ss from the
development version of Galore in case just in case.

-- 
Jens Axel Søgaard




-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: list.ss
URL: <http://lists.racket-lang.org/users/archive/attachments/20051018/e044b2c6/attachment.ksh>

Posted on the users mailing list.