Re: No CTFE of function

2017-08-28 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 26 August 2017 at 16:52:36 UTC, Cecil Ward wrote: I have a pure function that has constant inputs, known at compile-time, contains no funny stuff internally - looked at the generated code, and no RTL calls at all. But in a test call with constant literal values (arrays initialised

Re: No CTFE of function

2017-08-28 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 28 August 2017 at 03:16:24 UTC, Mike Parker wrote: On Sunday, 27 August 2017 at 17:47:54 UTC, Cecil Ward wrote: [...] The rules for CTFE are outlined in the docs [1]. What is described there is all there is to it. If those criteria are not met, the function cannot be executed at c

Re: No CTFE of function

2017-08-28 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 27 August 2017 at 00:08:45 UTC, Jonathan M Davis wrote: [...] Indeed. I used the term CTFE too loosely.

Re: No CTFE of function

2017-08-27 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 27 August 2017 at 17:47:54 UTC, Cecil Ward wrote: I wonder if there is anything written up anywhere about what kinds of things are blockers to either CTFE or to successful constant-folding optimisation in particular compilers or in general? Would be useful to know what to stay aw

Re: No CTFE of function

2017-08-27 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 27 August 2017 at 17:36:54 UTC, Cecil Ward wrote: On Sunday, 27 August 2017 at 00:20:47 UTC, ag0aep6g wrote: [...] Static had already been tried. Failed. Thanks to your tip, I tried enum next. Failed as well, wouldn't compile with GDC. [...] I wonder if there is anything writte

Re: No CTFE of function

2017-08-27 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 27 August 2017 at 00:20:47 UTC, ag0aep6g wrote: On 08/27/2017 01:53 AM, Cecil Ward wrote: On Saturday, 26 August 2017 at 23:49:30 UTC, Cecil Ward wrote: [...] I think I understand, but I'm not sure. I should have explained properly. I suspect what I should have said was that I was

Re: No CTFE of function

2017-08-26 Thread ag0aep6g via Digitalmars-d-learn
On 08/27/2017 01:53 AM, Cecil Ward wrote: On Saturday, 26 August 2017 at 23:49:30 UTC, Cecil Ward wrote: [...] I think I understand, but I'm not sure. I should have explained properly. I suspect what I should have said was that I was expecting an _optimisation_ and I didn't see it. I thought t

Re: No CTFE of function

2017-08-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, August 26, 2017 23:53:36 Cecil Ward via Digitalmars-d-learn wrote: > On Saturday, 26 August 2017 at 23:49:30 UTC, Cecil Ward wrote: > > On Saturday, 26 August 2017 at 18:16:07 UTC, ag0aep6g wrote: > >> On Saturday, 26 August 2017 at 16:52:36 UTC, Cecil Ward wrote: > >>> Any ideas as t

Re: No CTFE of function

2017-08-26 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 26 August 2017 at 23:53:36 UTC, Cecil Ward wrote: On Saturday, 26 August 2017 at 23:49:30 UTC, Cecil Ward wrote: [...] I was expecting this optimisation to 'return literal constant only' because I have seen it before in other cases with GDC. Obviously generating a call that invo

Re: No CTFE of function

2017-08-26 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 26 August 2017 at 23:49:30 UTC, Cecil Ward wrote: On Saturday, 26 August 2017 at 18:16:07 UTC, ag0aep6g wrote: On Saturday, 26 August 2017 at 16:52:36 UTC, Cecil Ward wrote: Any ideas as to why GDC might just refuse to do CTFE on compile-time-known inputs in a truly pure situation?

Re: No CTFE of function

2017-08-26 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 26 August 2017 at 18:16:07 UTC, ag0aep6g wrote: On Saturday, 26 August 2017 at 16:52:36 UTC, Cecil Ward wrote: Any ideas as to why GDC might just refuse to do CTFE on compile-time-known inputs in a truly pure situation? That's not how CTFE works. CTFE only kicks in when the *resul

Re: No CTFE of function

2017-08-26 Thread ag0aep6g via Digitalmars-d-learn
On Saturday, 26 August 2017 at 16:52:36 UTC, Cecil Ward wrote: Any ideas as to why GDC might just refuse to do CTFE on compile-time-known inputs in a truly pure situation? That's not how CTFE works. CTFE only kicks in when the *result* is required at compile time. For example, when you assign

No CTFE of function

2017-08-26 Thread Cecil Ward via Digitalmars-d-learn
I have a pure function that has constant inputs, known at compile-time, contains no funny stuff internally - looked at the generated code, and no RTL calls at all. But in a test call with constant literal values (arrays initialised to literal) passed to the pure routine GDC refuses to CTFE the