
Brian Hulley wrote:
Robin Green wrote:
<snip> So simply make strictness the default and have laziness annotations (for arguments), instead of making laziness the default and having strictness annotations.
Where would you put these laziness annotations? If you put them in the function declaration eg as in:
if' :: Bool -> ~a -> ~a -> a [corrected]
presumably you'd want the compiler to pass the args as thunks instead of evaluated values. However this means that all args to every function would have to be passed as thunks, even though for strict functions these thunks would immediately be evaluated. The problem is that there is no way for the compiler to optimize out the thunk creation / evaluation step because it occurs across the "black box" of a function call, thus we wouldn't get the same efficiency as in a language such as ML where no thunks are created in the first place.
I'm just soooo slow!!! ;-) Of course the laziness info would now be part of the function's type so the compiler would be able to generate the correct code to prepare thunks or evaluated values before calling the function. So your idea of laziness annotations for args would give the best of both worlds :-) Regards, Brian.