[racket] polymorphic functions

From: Răzvan Rotaru (razvan.rotaru at gmail.com)
Date: Sat Oct 13 16:18:27 EDT 2012


> ad hoc polymorphism, aka generics (the better word to avoid confusion):
if you want (length '(1 2 4)) == (length "123") == (length (vector 1 2 3)),
> then the historical response is that such functions violates the
carefully chosen middl ground of Scheme, which wants the readers (of code)
> understand from the function length, string-length, vector-length that
the program is currently dealing with lists, strings, or vectors.

Thanks for the quick answer to Matthias. I read it shortly after it was
sent, but I did not have the time to reply. What I mean by polymorphism is
what Matthias described as generics. So I am speaking about length applied
to anything that is a collection of things.

Somehow I fail to see the more pros than cons for this "middle ground
choice", but I don't intend to criticize it. I want explore whether I can
change the implementation of the core functions to make them generic. Say I
want to create a new language "generic scheme". :)

@Greg, I know sequences and the functions around it, and they are indeed
part of what I'm looking for. Essentially, I am speaking about replacing
the core scheme functions, which work with lists, with generic versions
that work with sequences. Before plunging into it, I would like to know
other oppinions (whether it's possible and/or what are the implications,

Regarding the generic interfaces that are currently experimental, I can
imagine this is a much awaited feature in racket. I wonder whether
performance will be an aspect that will be considered or not. As far as I
know this kind of functionality is usually implemented at a low level (in
the VM). I will keep an eye on the progress. :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121013/b1743b45/attachment.html>

Posted on the users mailing list.