tpapp:
> Hi,
> 
> I have a question about coding and compilers.  Suppose that a function
> is invoked with the same parameters inside another function declaration, eg
> 
> -- this example does nothing particularly meaningless
> g a b c = let something1 = f a b
>                     something2 = externalsomething (f a b) 42
>             something3 = externalsomething2 (137 * (f a b)) in
>             ...
> 
> Does it help (performancewise) to have
> 
> g a b c = let resultoff = f a b
>                     something2 = externalsomething resultoff 42
>             something3 = externalsomething2 (137 * resultoff) in
>             ...
> 
> or does the compiler perform this optimization?  More generally, if a
> function is invoked with the same parameters again (and it doesn't
> involve anything like monads), does does it makes sense
> (performancewise) to "store" the result somewhere?
> 

on the wiki,
    http://www.haskell.org/haskellwiki/Performance/GHC#Common_subexpressions

-- Don
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to