Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 08, 2018 03:51:11 David Bennett via Digitalmars-d-learn wrote: > On Thursday, 7 June 2018 at 04:58:40 UTC, Jonathan M Davis wrote: > > It would be trivial enough to create a wrapper template so that > > you can do something like > > > > immutable n = ctfe!(foo()); > > > > e.g. > >

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread jmh530 via Digitalmars-d-learn
On Friday, 8 June 2018 at 17:09:54 UTC, H. S. Teoh wrote: I would, if I had the time to spare to make such a chart. Perhaps you (or somebody here) could do it? It *is* a wiki, after all. Y'all don't have to wait for me to get around to it, the edit button is right there. T Fair

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 08, 2018 at 02:57:26PM +, jmh530 via Digitalmars-d-learn wrote: [...] > May I suggest that you add a flow chart that gives a very high level > understanding of the compiler steps. Like how Rust's introduction to > MIR has: > https://blog.rust-lang.org/2016/04/19/MIR.html I would,

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 08, 2018 at 02:36:01PM +, Gopan via Digitalmars-d-learn wrote: > On Friday, 8 June 2018 at 05:10:16 UTC, H. S. Teoh wrote: > > All this talk of CTFE and "compile-time", along with the confusion > > that arises from conflating everything done by the compiler into the > > blanket

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread jmh530 via Digitalmars-d-learn
On Friday, 8 June 2018 at 05:10:16 UTC, H. S. Teoh wrote: All this talk of CTFE and "compile-time", along with the confusion that arises from conflating everything done by the compiler into the blanket term "compile-time" makes me want to scream:

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread Gopan via Digitalmars-d-learn
On Friday, 8 June 2018 at 05:10:16 UTC, H. S. Teoh wrote: All this talk of CTFE and "compile-time", along with the confusion that arises from conflating everything done by the compiler into the blanket term "compile-time" makes me want to scream:

Re: Confusion/trying to understand CTFE keywords

2018-06-07 Thread H. S. Teoh via Digitalmars-d-learn
All this talk of CTFE and "compile-time", along with the confusion that arises from conflating everything done by the compiler into the blanket term "compile-time" makes me want to scream: https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time ;-) tl;dr: D's "compile-time"

Re: Confusion/trying to understand CTFE keywords

2018-06-07 Thread David Bennett via Digitalmars-d-learn
On Thursday, 7 June 2018 at 04:58:40 UTC, Jonathan M Davis wrote: It would be trivial enough to create a wrapper template so that you can do something like immutable n = ctfe!(foo()); e.g. template ctfe(alias value) { enum ctfe = value; } Would this be equivalent to using static

Re: Confusion/trying to understand CTFE keywords

2018-06-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 07, 2018 11:31:13 jmh530 via Digitalmars-d-learn wrote: > On Wednesday, 6 June 2018 at 22:19:58 UTC, Jonathan M Davis wrote: > > On Wednesday, June 06, 2018 18:18:16 jmh530 via > > > > Digitalmars-d-learn wrote: > >> On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote:

Re: Confusion/trying to understand CTFE keywords

2018-06-07 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 22:19:58 UTC, Jonathan M Davis wrote: On Wednesday, June 06, 2018 18:18:16 jmh530 via Digitalmars-d-learn wrote: On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote: > [snip] > > If you haven't yet, I'd suggest reading Would make a good blog series?

Re: Confusion/trying to understand CTFE keywords

2018-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 07, 2018 04:41:35 Gopan via Digitalmars-d-learn wrote: > On Tuesday, 5 June 2018 at 22:08:32 UTC, Stefan Koch wrote: > > On Tuesday, 5 June 2018 at 18:00:05 UTC, Steven Schveighoffer > > > > wrote: > >> No, it's definitely a bug. main is not being evaluated at > >> compile time.

Re: Confusion/trying to understand CTFE keywords

2018-06-06 Thread Gopan via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 22:08:32 UTC, Stefan Koch wrote: On Tuesday, 5 June 2018 at 18:00:05 UTC, Steven Schveighoffer wrote: No, it's definitely a bug. main is not being evaluated at compile time. The real result of this function should be a compile-time error -- __ctfe is a *runtime*

Re: Confusion/trying to understand CTFE keywords

2018-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 06, 2018 18:18:16 jmh530 via Digitalmars-d-learn wrote: > On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote: > > [snip] > > > > If you haven't yet, I'd suggest reading > > Would make a good blog series? What would make a good blog series? Something talking about

Re: Confusion/trying to understand CTFE keywords

2018-06-06 Thread jmh530 via Digitalmars-d-learn
On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote: [snip] If you haven't yet, I'd suggest reading Would make a good blog series?

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 05, 2018 22:08:32 Stefan Koch via Digitalmars-d-learn wrote: > On Tuesday, 5 June 2018 at 18:00:05 UTC, Steven Schveighoffer > > wrote: > > No, it's definitely a bug. main is not being evaluated at > > compile time. The real result of this function should be a > > compile-time

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 18:00:05 UTC, Steven Schveighoffer wrote: No, it's definitely a bug. main is not being evaluated at compile time. The real result of this function should be a compile-time error -- __ctfe is a *runtime* value that is always defined based on whether you are __ctfe

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/18 12:10 PM, Stefan Koch wrote: This is not bug just not very intuitive. Since you are declaring a static array the value of n needs to known at compiletime. so it'll  try to evaluate n at an compile-time context in which n is 1. however when code-generation for the function is done

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 13:27:35 UTC, Steven Schveighoffer wrote: On 6/5/18 6:40 AM, Simen Kjærås wrote: On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: void main() {     immutable n = __ctfe ? 1 : 2;     int[n] a;     assert(a.length == n); // fails, wat } That's gotta be a bug -

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/18 6:40 AM, Simen Kjærås wrote: On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: void main() {     immutable n = __ctfe ? 1 : 2;     int[n] a;     assert(a.length == n); // fails, wat } That's gotta be a bug - that should give a 'variable n cannot be read at compile time' error.

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 05, 2018 11:18:05 Gopan via Digitalmars-d-learn wrote: > On Tuesday, 5 June 2018 at 10:40:20 UTC, Simen Kjærås wrote: > > On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: > >> void main() > >> { > >> > >> immutable n = __ctfe ? 1 : 2; > >> int[n] a; > >>

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Gopan via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 10:40:20 UTC, Simen Kjærås wrote: On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: void main() { immutable n = __ctfe ? 1 : 2; int[n] a; assert(a.length == n); // fails, wat } That's gotta be a bug - that should give a 'variable n cannot be read at

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: void main() { immutable n = __ctfe ? 1 : 2; int[n] a; assert(a.length == n); // fails, wat } That's gotta be a bug - that should give a 'variable n cannot be read at compile time' error. The fact that n is immutable shouldn't

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Gopan via Digitalmars-d-learn
On Sunday, 3 June 2018 at 21:32:06 UTC, gdelazzari wrote: Couldn't a keyword like "ctfe" (just making it up right now) exist? So that, when seeing something like ctfe myNumber = 5; ctfe if (myNumber + 2 == 7) { // ... } one could immediately understand that the code is executed/evaluated

Re: Confusion/trying to understand CTFE keywords

2018-06-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 04, 2018 14:05:28 gdelazzari via Digitalmars-d-learn wrote: > On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote: > > So, while static _seems_ somewhat inconsistent at first, the > > way it's used is pretty consistent overall. The main > > inconsistency is the places

Re: Confusion/trying to understand CTFE keywords

2018-06-04 Thread gdelazzari via Digitalmars-d-learn
On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote: I think that part of your problem here comes from the fact that you think of enum or static are "CTFE keywords." That's not what they are at all. Yes, they can trigger CTFE, but they're not the only way. ... Thank you very

Re: Confusion/trying to understand CTFE keywords

2018-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 03, 2018 21:32:06 gdelazzari via Digitalmars-d-learn wrote: > Hello everyone, I'm new here on the forum but I've been exploring > D for quite a while. I'm not an expert programmer by any means, > so this one may be a really silly question and, in that case, > please forgive me. > >

Re: Confusion/trying to understand CTFE keywords

2018-06-03 Thread Dave Jones via Digitalmars-d-learn
On Sunday, 3 June 2018 at 21:32:06 UTC, gdelazzari wrote: Note that this is not an attack to the language or anything (I actually really love it), I'm just trying to understand the reasoning behind this choice. Because they have a thing about not adding new keywords, apparently it's more

Re: Confusion/trying to understand CTFE keywords

2018-06-03 Thread Computermatronic via Digitalmars-d-learn
On Sunday, 3 June 2018 at 21:32:06 UTC, gdelazzari wrote: I'm trying to understand why keywords such as "static" or "enum" are used to denote compile time "things". What I mean is that those keywords are also used for other purposes, so I find it a bit confusing. Couldn't a keyword like "ctfe"

Confusion/trying to understand CTFE keywords

2018-06-03 Thread gdelazzari via Digitalmars-d-learn
Hello everyone, I'm new here on the forum but I've been exploring D for quite a while. I'm not an expert programmer by any means, so this one may be a really silly question and, in that case, please forgive me. With the premise that I've still not looked a lot into "complex" compile time