Aaron Denney <wnoise@ofb.net> writes:
With a recursive function of more than one argument, does it make sense to keep the arguments that tend to remain constant closer to the front?
i.e.
Will any implementations notice interp y x:xs calls interp y, and keep some sort of interp y partial application around?
Hugs (and before it, Gofer) implements this optimisation. It saves a small amount of memory by re-using the "root" portion of the original call in the recursive call. As far as I know, no other implementation makes use of this possibility, mainly because every system except Hugs uses vector heap cells instead of chained binary cells. I.e. in ghc, hbc, or nhc98, the function application is represented internally as ( interp y xs ) whereas in Hugs it is represented as ( ( interp y ) xs ) and the latter enables the re-use of the leading portion, whilst the former does not. Regards, Malcolm