digitalmars.D.bugs - [Issue 3921] New: Compile time evaluation requirements not well-specified
- d-bugmail puremagic.com (28/28) Mar 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3921
- d-bugmail puremagic.com (20/21) Mar 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3921
- d-bugmail puremagic.com (18/34) Mar 11 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3921
- d-bugmail puremagic.com (13/24) Jan 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3921
http://d.puremagic.com/issues/show_bug.cgi?id=3921 Summary: Compile time evaluation requirements not well-specified Product: D Version: 2.041 Platform: All URL: file:///home/jlquinn/dmd2/html/d/function.html OS/Version: All Status: NEW Keywords: spec Severity: major Priority: P2 Component: www.digitalmars.com AssignedTo: nobody puremagic.com ReportedBy: jlquinn optonline.net --- The language of the spec does not clearly state what a compile must be able to evaluate at compile time. Through example, clearly constant folding must be done, to support mixins as shown in various examples, but the full rules of what the D language requires to be done at compile time is not given. Similarly, CTFE states that the compiler can execute functions at compile time if they meet certain constraints. However, it doesn't clearly state whether the D language requires that these functions be executed at compile time. Other writing I've seen suggests that CTFE is an optimization, not a language requirement. What exactly is required of any D compiler? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3921 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au Quoting the spec: "In order to be executed at compile time, the function must appear in a context where it must be so executed" Note the word MUST. I don't see anything in the spec to indicate that it is optional. It's pretty simple actually -- if the compiler *needs* a constant, and it sees an expression, it attempts to constant-fold that expression. If the expression contains a function call, CTFE will be used. CTFE is not used in any other context - it never happens unless requested.Other writing I've seen suggests that CTFE is an optimization, not a languagerequirement. Can you remember where you saw that writing, or got that impression? If it's anywhere public, we need to get rid of it, since it is not correct. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3921 ---Quoting the spec: "In order to be executed at compile time, the function must appear in a context where it must be so executed" Note the word MUST. I don't see anything in the spec to indicate that it is optional.No, the language above says that the correct function context is necessary, not sufficient. CTFE won't succeed unless the condition is met. It definitely does not say that the compiler is required to try.It's pretty simple actually -- if the compiler *needs* a constant, and it sees an expression, it attempts to constant-fold that expression. If the expression contains a function call, CTFE will be used. CTFE is not used in any other context - it never happens unless requested.In principle, it's simple. But typically constant folding is an optimization, not a requirement in languages, so D is relatively unique in this regard. It's important for the spec to explicitly say so rather than imply through example.I can't find what I thought I read about. So it's possible I hallucinated that and it's a false impression. I still think that the fact that the compiler is guaranteed to execute expressions and functions at compile time has to be more clearly stated, though. Also, the rules for expressions to be executed at compile time should also be explicitly stated, separate from the function rules. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Other writing I've seen suggests that CTFE is an optimization, not a languagerequirement. Can you remember where you saw that writing, or got that impression? If it's anywhere public, we need to get rid of it, since it is not correct.
Mar 11 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3921 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |INVALID 15:41:42 PST ---The second 'must' covers it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Quoting the spec: "In order to be executed at compile time, the function must appear in a context where it must be so executed" Note the word MUST. I don't see anything in the spec to indicate that it is optional.No, the language above says that the correct function context is necessary, not sufficient. CTFE won't succeed unless the condition is met. It definitely does not say that the compiler is required to try.
Jan 23 2012