[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] WG2 Scheme and Polymporphism

Denis Washington scripsit:

> (I am neither a WG1 or WG2 member, but I care a lot about Scheme.)

I very much hope you will join WG2 when it comes out of hibernation.
The nice thing about belonging to WG2 is that you don't have to be
interested in everything the WG is doing, just willing to do some work
on some of the things.

> Unfortunately, Scheme lacks support for polymorphism almost
> everywhere; with the notable exception of arithmetic procedures, most
> of R5RS' (and R7RS') standard procedures are through and through
> non-polymorphic.

Non-generic procedures can be implemented more efficiently, and you can
build generic procedures on top of them.

> For instance, writing a generic version of "map" or "filter" would
> require an ugly "cond" expression handling each type of sequence
> individually.

That COND has to exist somewhere, even in explicitly OO languages.  If
you don't want to see it, that's why we have macros.

Alaric Snell-Pym scripsit:

> I'd quite like to see generic functions defined orthogonally to
> records-with-inheritance, too, if possible.

I wrote a little generic functions package for Chibi that doesn't
use any syntactic sugar, and allows arbitrary predicates for type
discrimination on all arguments, all in one page of code.  It's up to
the programmer to specify the methods in the right order, though, since
the package can't tell which predicates subsume which others.

See http://tinyurl.com/chibi-pgf , and export make-pgf, handle, and

> With one caveat: the effect of inherited getters/setters is very
> similar to generic functions dispatched on the record type, so it
> might be worthwhile specifying that they are always generic functions
> [...] so that folks can add their own methods to the getter/setter GFs

I disagree here: it's possible to make setters and getters very
efficient (more efficient than vector access, in fact, since they need
not check for index out of range) if they are *not* generic, as long
as records have either no inheritance or single inheritance.  Chibi's
design is exemplary in this respect.  It also uses a very clever trick
for record predicates that takes O(1) time to determine if a record
belongs to a given type.

Andre van Tonder scripsit:

> Scheme already has tons of polymorphic procedures, e.g. CONS.

Well, yes, but only because CONS is not interested in the types of its
arguments.  Universal polymorphism is trivial in dynamically typed

> But in general this kind of programming is overrated.

So are computers in general.  The total productivity gains, at least in
the U.S., from putting a computer on every office worker's desk turn out
to be essentially zero.

But somehow we like to play with them anyway.

> Object-oriented languages have failed miserably in delivering on their
> initial promise.

I didn't put any OO packages on the ballot for fear of going down a
rathole; people often feel strongly about specific OO packages, or about
not having one.  If there's enough pressure from WG2 members, they can
be balloted when WG2 wakes up.

John Cowan  cowan@x  http://ccil.org/~cowan
Linguistics is arguably the most hotly contested property in the academic
realm. It is soaked with the blood of poets, theologians, philosophers,
philologists, psychologists, biologists and neurologists, along with
whatever blood can be got out of grammarians. - Russ Rymer

Scheme-reports mailing list