On Oct 3, 2006, at 11:47 PM, skaller wrote: > On Mon, 2006-10-02 at 09:40 -0400, Peter Tanski wrote: > >>> Typeclasses and instances have to be toplevel: that is, >>> they can be nested in modules but NOT in functions. >> >> It wouldn't make sense if typeclasses were nested in functions. > > Why not? > > They're allowed in programs .. and a program is just a function.
I knew you were going to say that :) Typeclasses exist to scope over types and in a functional world types only make sense when they scope over multiple functions. If you had a single function with no nested functions--the compiler may actually create nested functions, such as the GNU extension to C, as a separate function anyway--defining a type within the function for even a few procedures would not make any real a difference. You can imagine the scenario: a typedef within a function would really operate only as syntactic sugar since you would have to (1) create the type and (2) destroy the type before returning from the function itself. As a practical matter, in a language with functional features and in any "functional" language function-nested types would be very difficult (if not impossible) to support. Here is another model: logic or mathematics use notations that operate universally over at least a subset of equations--creating a notation that operated over a single equation would be redundant, worthless and even confusing. -Pete ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Felix-language mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/felix-language
