[plt-scheme] polymorphism of primitive types

From: Yoav Goldberg (yoav.goldberg at gmail.com)
Date: Mon Oct 17 19:41:46 EDT 2005


I would really like to be able treat my own sequential data (such as
streams, or trees) as lists, ie, to have "car" "cdr" "map" "list-ref"
"length" etc work on regular lists as well as on streams (and the
other relevant data types).

In python this is really easy - you make a class, define it's
__iter__() and next() methods, and you can use it anywhere you would
use a list. Very handy. What's the best way to achieve the same effect
in MzScheme? (what's the most efficient way to achieve the
polymorphism, and what is the minimal set of functions I'll be
required to implement for each new type?)


Posted on the users mailing list.