[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dictionaries are sometimes not necessary
Original-Via: uk.ac.nsf; Sat, 2 Mar 91 02:54:54 GMT
Date: Fri, 1 Mar 91 11:10:05 GMT
From: Mark.Jones@prg.oxford.ac.uk
To: haskell@edu.yale.cs
Subject: Re: Dictionaries are sometimes not necessary
Sender: haskell-request@cs.glasgow.ac.uk
The implementation of type classes suggested by Evan Ireland is similar
in some ways to the approach that I am suggesting.
| For example, if a program makes use of the (overloaded) equality function
| on [Int], [[Char]], and [Integer], I would envisage generating three
| closures for the list equality function.
Wouldn't you actually need four of them - one for each of [Int], [Integer],
[[Char]] _and_ [Char]?
|(2) The explosion occurs once, at the beginning of program execution, and the
| closures are subsequently available for garbage collection (when they are
| no longer referenced, of course).
With the implementation that I'm suggesting the `explosion' also occurs
just once. I have been assuming that this work would be incorporated into
the compilation process although there does not seem to be any practical
reason why it could not be done as part of the program initialisation at
run-time. Personally I'd prefer if it were done in the compiler (or more
accurately perhaps, the module link/loading process?) so that we can avoid
the run-time penalty.
|(3) I don't need to build any dictionaries.
Perhaps you're not calling them dictionaries, but they are still there, at
least in part: the values of the free variables (+), (-) and (*) in the
example you give are simply the portion of the dictionary for Num a that
your example function f requires.
|(5) I have not implemented this yet.
Good luck!
Mark