Annotation for unfolding wanted

Simon Peyton-Jones simonpj at microsoft.com
Wed Aug 1 04:06:10 EDT 2007


If it's tail recursive it'll be compiled to a loop.  You don't need a pragma.

Of course if it does evaluation along the way, it'll have to make a call do to that evaluation.  E.g.
        f x = if x>0 then 0 else f (g x)
Here f is tail-rec but it'll have to call g inside the loop.

Simon

| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-users-bounces at haskell.org] On
| Behalf Of Georg Martius
| Sent: 01 August 2007 08:43
| To: Simon Peyton-Jones; Glasgow-haskell-users at haskell.org
| Subject: Re: Annotation for unfolding wanted
|
| Hi,
|
| I am sorry for using the wrong terminology here. Let me ask again:
| Does it sound reasonable to extend the compiler with a pragma that specifies
| that a certain function should be compiled to a loop? And if the compiler can
| not do it, it helps with some error message.
|
| Regards!
|         Georg
|
| On Tuesday 31 July 2007 16:20, Simon Peyton-Jones wrote:
| > | However my point was more on a semantic point of view: If I write a
| > | function in a recursive way, but actually do nothing else than a loop, I
| > | would like a) that the compiler unrolls it to a loop and
| > | b) that I can specify such a requirement, while violating it emits an
| > | error.
| >
| > What does it mean to say "the compiler unrolls it to a loop".  If GHC sees
| > a tail recursive function, it certainly compiles it to a loop!  (But that's
| > not called "unrolling".)
| >
| > Simon
|
| --
| ---- Georg Martius,  Tel: +49 177 6413311  -----
| ------- http://www.flexman.homeip.net ----------


More information about the Glasgow-haskell-users mailing list