Hello, I've got two questions regarding bindings in Haskell: 1. Is there something like a strict "let!" for avoiding function closures by forcing strict evaluation (to headnormalform) of local declarations? 2. In a '93 paper, Jan Sparud describes an implementation technique for avoiding space leaks when tuples are returned as function result, and the values accessed by pattern matching in bindings. The paper says this technique (of shorcircuiting all references via a tuple, the first time a tuple element is demanded) has been implemented in Chalmers LML/HBC compiler. What about other compilers, e.g. GHC? Any hint would be helpful. Thanks, Janis. -- Janis Voigtlaender email: voigt@tcs.inf.tu-dresden.de
1. Is there something like a strict "let!" for avoiding function closures by forcing strict evaluation (to headnormalform) of local declarations?
Not that I am aware of. You must do it explicitly with `seq`.
2. In a '93 paper, Jan Sparud describes an implementation technique for avoiding space leaks when tuples are returned as function result, and the values accessed by pattern matching in bindings. The paper says this technique (of shorcircuiting all references via a tuple, the first time a tuple element is demanded) has been implemented in Chalmers LML/HBC compiler. What about other compilers, e.g. GHC?
It is certainly implemented in nhc98, not just for tuples, but for selectors of any constructed type. Regards, Malcolm
Janis Voigtlaender <voigt@orchid.inf.tu-dresden.de> writes:
2. In a '93 paper, Jan Sparud describes an implementation technique for avoiding space leaks when tuples are returned as function result, and the values accessed by pattern matching in bindings. The paper says this technique (of shorcircuiting all references via a tuple, the first time a tuple element is demanded) has been implemented in Chalmers LML/HBC compiler. What about other compilers, e.g. GHC?
GHC's garbage collector will "short-circuit" thunks of the form: selector@object where the object is in whnf (If I remember the paper correctly) this is slightly different from Jan Sparud's technique which did the short-circuiting in the evaluator. I'm pretty sure Hugs doesn't implement either. The GC version might be straightforward to add. -- Alastair Reid reid@cs.utah.edu http://www.cs.utah.edu/~reid/
participants (3)
-
Alastair David Reid -
Janis Voigtlaender -
Malcolm Wallace