[jhc] Loops.

John Meacham john at repetae.net
Thu Mar 20 18:44:01 EDT 2008


On Thu, Mar 20, 2008 at 12:51:20PM -0500, Samuel Bronson wrote:
> On 3/20/08, John Meacham <john at repetae.net> wrote:
> > in core, so it is not recognized as a loop. I doubt it will be much of a
> > problem in practice, and eta reduction is an anti-optimization in
> > general.
> 
> Why isn't that recognized as a loop? Isn't it typically beneficial in
> the body of a function to replace calls like that with the return
> value? For example:
> 
> fix :: (a -> a) -> a
> fix f = f (fix f)

Oh, it is recognized as recursive*, but not as an infinite loop. When
the jhc optimizer comes across something it knows is equivalent to
bottom, it replaces it with 'error "<<loop>>"'. ghc does the same thing.
it is this replacement that jhc wasn't doing, which is okay since the
replacement is really just an optimization jhc will take advantage of
when it can find, but doesn't look to hard for. (though, other
optimizations likely expose more 'manifest loops'.

* though the fact jhc is blowing stack means that perhaps there is a bug
  whereby it isn't being recognized as recursive.

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the jhc mailing list