effect of order of function arguments

Aaron Denney wnoise@ofb.net
Tue, 18 Feb 2003 21:59:36 -0800


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. is this:

> interp :: a -> [a] -> [a]
> interp y   []   =  []
> interp y (x:[]) = x:[]
> interp y (x:xs) = x:y:interp y xs

any better than this:

> interp :: [a] -> a -> [a]
> interp   []   y =  []
> interp (x:[]) y = x:[]
> interp (x:xs) y = x:y:interp xs y

Will any implementations notice interp y x:xs calls interp y, and keep
some sort of interp y partial application around?

(I don't really expect any effect like this, but even if there were one,
I would expect consideration like the fact that "interp constant" is a
useful function, while "\x -> interp x const-list" is not so useful to
outweigh any such effect.  Happily, they don't conflict here.  If there
is no effect like this, would it make any sense to try to get something
similar by hand, and can this actually be done?)

-- 
Aaron Denney
-><-