Re: Annotation for unfolding wanted

2007-08-03 Thread Isaac Dupree
Simon Peyton-Jones wrote: If it's tail recursive it'll be compiled to a loop. You don't need a pragma. The ~pragma is in order to make an error if it's not a loop. Same way as we don't need type-signatures in export lists and their only purpose is to cause errors when something unexpected an

Re: Annotation for unfolding wanted

2007-08-01 Thread Claus Reinke
Some compilers unroll recursive functions by inlining them N times, for some fixed N (say 3 or so). This reduces the loop overheads. GHC doesn't do this, although it'd be nice, because it makes repeated traversals of the code, and it's hard to spot when the function has been unrolled 3 times an

Re: Annotation for unfolding wanted

2007-08-01 Thread Stefan O'Rear
On Wed, Aug 01, 2007 at 09:42:54AM +0200, Georg Martius wrote: > 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 ca

RE: Annotation for unfolding wanted

2007-08-01 Thread Simon Peyton-Jones
ll g inside the loop. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On | Behalf Of Georg Martius | Sent: 01 August 2007 08:43 | To: Simon Peyton-Jones; Glasgow-haskell-users@haskell.org | Subject: Re: Annotation for unfolding wanted | | Hi, | | I am sorry for usin

Re: Annotation for unfolding wanted

2007-08-01 Thread Georg Martius
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

RE: Annotation for unfolding wanted

2007-07-31 Thread Simon Peyton-Jones
| > {-# INLINE f #-} | > f x y z = ... f x' y' z' ... | > | > into this: | > | > {-# INLINE f #-} | > f x y z = f' x y z | >where f' x y z = ... f' x' y' z' ... | > | > That is, shoving (all of) the recursion in a level. Then inlining f | > results in a fresh loop, which presumably can be spe

Re: Annotation for unfolding wanted

2007-07-31 Thread Duncan Coutts
On Tue, 2007-07-31 at 10:36 -0400, Jan-Willem Maessen wrote: > I think what's meant here is translating something like this: > > {-# INLINE f #-} > f x y z = ... f x' y' z' ... > > into this: > > {-# INLINE f #-} > f x y z = f' x y z >where f' x y z = ... f' x' y' z' ... > > That is, shov

Re: Annotation for unfolding wanted

2007-07-31 Thread Jan-Willem Maessen
On Jul 31, 2007, at 10:20 AM, 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

RE: Annotation for unfolding wanted

2007-07-31 Thread Simon Peyton-Jones
| 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 me

Re: Annotation for unfolding wanted

2007-07-31 Thread Georg Martius
Hi Simon, thanks for the answer! I see why inlining is not a good idea, but why is it not unfolded. I mean we don't need any true recursion if the function is tail-recursive or am I mistaken? However my point was more on a semantic point of view: If I write a function in a recursive way, but ac

RE: Annotation for unfolding wanted

2007-07-31 Thread Simon Peyton-Jones
| I was wondering why we don't have an annotation or pragma for function to tell | the compiler that we _need_ this particular recursive function to be unfolded. | If the compiler cannot do this for some reason it should produce an error | message to help you modifying your code. I have regularly p