Inlining question
Adrian Hey
ahey at iee.org
Mon Apr 19 12:27:18 EDT 2004
On Monday 19 Apr 2004 9:52 am, Simon Peyton-Jones wrote:
> | > Does inlining work with any function definitions (including those
> | > defined locally following a where.. say), or only with top level
> | > function definitions?
>
> If you mean
>
> In GHC, if I use an {-# INLINE #-} pragma on a
> nested function definition, should it be inlined?
Yes, sorry if I wasn't clear, that is what I mean.
> then the answer is yes, unless the function is recursive in which case
> the pragma is ignored.
The function is indirectly recursive, in that I have a pair of mutually
recursive functions, one of which I want to inline (so it becomes a single
recursive function).
Of course this means I'd have to move them both to the top level if that
was required to inline one of them, or maybe add another function
argument to the one being lifted (but this shouldn't be necessary anyway
going by what you've just told me).
> Do you have reason to suppose the contrary? If so, do send a test case
Well I'm just going by comparison of the resulting object files, but it
seemed that they were identical whether I used {-# INLINE foo #-},
{-# NOINLINE foo #-}, or nothing at all. If you think that shouldn't be
the case I'll have another go. Perhaps I was doing something stupid.
I have another question if I may. Does inlining occur before or after
strictness analysis? (and would it make any difference to the results
of strictness analysis anyway?)
I imagine it would make a difference of the function being inlined takes
other functions with known strictness properties as arguments, but I may
well be wrong :-)
Thanks
--
Adrian Hey
More information about the Glasgow-haskell-users
mailing list