digitalmars.D - Stroustrup's slides about c++11 and c++14
- eles (14/14) Sep 13 2014 This presentation:
- ketmar via Digitalmars-d (5/5) Sep 13 2014 On Sat, 13 Sep 2014 20:10:53 +0000
- Paulo Pinto (10/16) Sep 13 2014 I agree with him.
- Joakim (5/20) Sep 13 2014 Heh, I like how he says static if was proposed by "Walter Brown."
- po (3/7) Sep 13 2014 Walter Brown is a real person;)
- Walter Bright (9/22) Sep 13 2014 Yeah, well, we have many years of experience with "static if" and no apo...
- Paulo Pinto (5/9) Sep 13 2014 In that sense, regardless of D's future, I would say it is already a big...
- Peter Alexander (7/9) Sep 13 2014 Well, we are yet to define "static if" when it comes to tricky
- Timon Gehr (9/16) Sep 13 2014 Note that DIP31 is quite weak because 'order of appearance in the
- Andrei Alexandrescu (18/47) Sep 13 2014 D offers strong evidence that static if is an enormously useful
- bearophile (6/8) Sep 13 2014 But it's not a complete typing. The Concepts Lite are a more
- Walter Bright (2/5) Sep 13 2014 "parallel construction" :-)
- Paolo Invernizzi (5/7) Sep 14 2014 I've had the same impressions...
- deadalnix (11/56) Sep 14 2014 To be fair, the way it is implemented right now is a hack, and it
- Andrei Alexandrescu (4/6) Sep 14 2014 That hasn't been a problem. There are many hacks that have been
- bearophile (11/13) Sep 15 2014 D and C++ compete for a similar programming niche, but C++ is so
- Andrei Alexandrescu (11/22) Sep 15 2014 Just for fun...
- SomeDude (3/16) Sep 29 2014 The problem is, the C++ community is unwilling to collaborate
- deadalnix (3/5) Sep 29 2014 What makes you think so ? I'm not telling you are wrong, simply
- bearophile (9/11) Sep 29 2014 The C++ language has plenty of warts and unnecessary
- Walter Bright (2/2) Sep 29 2014 Looks like this made it to reddit:
- eles (6/8) Sep 30 2014 I think the correct counter-attack is simply to write a note
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (8/12) Sep 30 2014 It is probably not a good idea to bring more attention to it…
- Timon Gehr (18/29) Sep 13 2014 In D, { ... } has this other meaning even without static if and I would
- Daniel Murphy (4/9) Sep 14 2014 I do acknowledge this is a problem, but I am yet to run into it in actua...
- Walter Bright (8/11) Sep 14 2014 A similar problem once existed in the druntime, which caused a bunch of
- eles (4/7) Sep 14 2014 I agree. Let's not forget that the complication of C and C++
- deadalnix (3/17) Sep 14 2014 If that is really a concern, please consider commenting on
- Walter Bright (8/10) Sep 14 2014 I haven't thought it through, but the DIP looks like a good idea.
- Timon Gehr (3/13) Sep 14 2014 (It is furthermore also important that most programs that are not
- Timon Gehr (10/28) Sep 14 2014 To elaborate a little: The following simple test case cannot be accepted...
- Dicebot (3/36) Sep 17 2014 I remember deadlnix telling quite a lot of nice stories about how
- David Nadlinger (12/16) Sep 14 2014 I tend to run into forward referencing issues all the time
- David Nadlinger (3/5) Sep 14 2014 Whoops, a "with"/"when doing" went missing there.
- Dicebot (6/23) Sep 17 2014 Yes, this is not uncommon way to hit the wall. Separating
- deadalnix (10/18) Sep 14 2014 I can provide first hand experience on taht one, having them
- Peter Alexander (14/16) Sep 14 2014 The way I interpret it is that (for template constraints), they
- Elie Morisse (14/23) Sep 14 2014 The lack of « something like static if » in C++ and his
- Sean Cavanaugh (4/18) Sep 14 2014 Its a downright cute and cuddly abomination to have as opposed to the
This presentation: https://parasol.tamu.edu/people/bs/622-GP/C++14TAMU.pdf He criticizes C99 VLA (slide 24) as being "an abomination" But the surprise comes at the end (slide 57), where he also criticizes... the static if as being "a total abomination". Well, this is D, I told myself. Are those points valid?: static if is a total abomination • Unstructured, can do everything (just like goto) • Complicates static analysis (AST-based tools get hard to write) • Blocks the path for concepts • Specifies how things are done (implementation) • Is three slightly different “ifs” using a common syntax • Redefines the meaning of common notation (such as { ... })
Sep 13 2014
On Sat, 13 Sep 2014 20:10:53 +0000 eles via Digitalmars-d <digitalmars-d puremagic.com> wrote: even if he crated one of the worst known abominations on the planet this still doesn't mean that he is any kind of expert in abomination analysis.
Sep 13 2014
Am 13.09.2014 22:10, schrieb eles:This presentation: https://parasol.tamu.edu/people/bs/622-GP/C++14TAMU.pdf He criticizes C99 VLA (slide 24) as being "an abomination"I agree with him. C99 VLA are the typical open door to security exploits via the stack frame, that C brought upon the IT world. To the point C11, which took security as one of the goals, has made VLA optional.But the surprise comes at the end (slide 57), where he also criticizes... the static if as being "a total abomination". Well, this is D, I told myself.Well, Bjarne has his own proposal, concepts, so there is a bit of salesman speech here, I would say. -- Paulo
Sep 13 2014
On Saturday, 13 September 2014 at 20:10:55 UTC, eles wrote:This presentation: https://parasol.tamu.edu/people/bs/622-GP/C++14TAMU.pdf He criticizes C99 VLA (slide 24) as being "an abomination" But the surprise comes at the end (slide 57), where he also criticizes... the static if as being "a total abomination". Well, this is D, I told myself. Are those points valid?: static if is a total abomination • Unstructured, can do everything (just like goto) • Complicates static analysis (AST-based tools get hard to write) • Blocks the path for concepts • Specifies how things are done (implementation) • Is three slightly different “ifs” using a common syntax • Redefines the meaning of common notation (such as { ... })Heh, I like how he says static if was proposed by "Walter Brown." ;) Is it just me or did it seem like most of the stuff in those slides is already in D? I don't follow C++.
Sep 13 2014
Heh, I like how he says static if was proposed by "Walter Brown." ;) Is it just me or did it seem like most of the stuff in those slides is already in D? I don't follow C++.Walter Brown is a real person;) The C++ dynarray stuff was appealing to me, but it got delayed, and who knows if it will appear again:(
Sep 13 2014
On Saturday, 13 September 2014 at 21:54:19 UTC, po wrote:Ah, I now see that he is, since he's listed in the footnotes for the full Stroustrup rebuttal that Walter just linked, a researcher from Fermilab with his own static if proposal. Still funny that this Walter was left out, although Bjarne probably sees so many names and people, maybe they just blended together in his mind. ;)Heh, I like how he says static if was proposed by "Walter Brown." ;) Is it just me or did it seem like most of the stuff in those slides is already in D? I don't follow C++.Walter Brown is a real person;)
Sep 14 2014
On Sunday, 14 September 2014 at 07:42:14 UTC, Joakim wrote:On Saturday, 13 September 2014 at 21:54:19 UTC, po wrote:Bjarnes simply don't want to admit that Walter is bright.Ah, I now see that he is, since he's listed in the footnotes for the full Stroustrup rebuttal that Walter just linked, a researcher from Fermilab with his own static if proposal. Still funny that this Walter was left out, although Bjarne probably sees so many names and people, maybe they just blended together in his mind. ;)Heh, I like how he says static if was proposed by "Walter Brown." ;) Is it just me or did it seem like most of the stuff in those slides is already in D? I don't follow C++.Walter Brown is a real person;)
Sep 14 2014
On 9/13/2014 1:10 PM, eles wrote:This presentation: https://parasol.tamu.edu/people/bs/622-GP/C++14TAMU.pdf He criticizes C99 VLA (slide 24) as being "an abomination" But the surprise comes at the end (slide 57), where he also criticizes... the static if as being "a total abomination". Well, this is D, I told myself. Are those points valid?: static if is a total abomination • Unstructured, can do everything (just like goto) • Complicates static analysis (AST-based tools get hard to write) • Blocks the path for concepts • Specifies how things are done (implementation) • Is three slightly different “ifs” using a common syntax • Redefines the meaning of common notation (such as { ... })Yeah, well, we have many years of experience with "static if" and no apocalypse has yet happened. The proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3329.pdf Bjarne's rebuttal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3613.pdf C++ is adopting D features anyway. The constexpr proposals are looking a lot like CTFE :-)
Sep 13 2014
Am 14.09.2014 00:25, schrieb Walter Bright:On 9/13/2014 1:10 PM, eles wrote:In that sense, regardless of D's future, I would say it is already a big win to have that influence over C++'s design decisions. __ Paulo[...]C++ is adopting D features anyway. The constexpr proposals are looking a lot like CTFE :-)
Sep 13 2014
On Saturday, 13 September 2014 at 22:25:57 UTC, Walter Bright wrote:Yeah, well, we have many years of experience with "static if" and no apocalypse has yet happened.Well, we are yet to define "static if" when it comes to tricky cases, i.e. cases where static ifs and mixins have interdependencies. http://wiki.dlang.org/DIP31 Would be good to have a resolution on this.
Sep 13 2014
On 09/14/2014 01:21 AM, Peter Alexander wrote:On Saturday, 13 September 2014 at 22:25:57 UTC, Walter Bright wrote:Note that DIP31 is quite weak because 'order of appearance in the source' is not well-defined for constructs appearing in files that cyclically import each other and the 'poison mode' is IMO enabled too often. However, I get quite promising results using explicit dependency tracking, running analysis until it is stuck on symbol lookup and then poisoning the symbols in the topmost strongly connected component of the dependency graph. I still need to find a good way to make nested template instantiation fast enough with this approach though.Yeah, well, we have many years of experience with "static if" and no apocalypse has yet happened.Well, we are yet to define "static if" when it comes to tricky cases, i.e. cases where static ifs and mixins have interdependencies. http://wiki.dlang.org/DIP31 Would be good to have a resolution on this.
Sep 13 2014
On 9/13/14, 3:25 PM, Walter Bright wrote:On 9/13/2014 1:10 PM, eles wrote:D offers strong evidence that static if is an enormously useful construct. I have all respect for Bjarne as language designer, researcher, and engineer, but the evidence suggest he called this wrong. He is right that static if would have derailed work on concepts, because it simply exposes them as missing the point. From that perspective N3613 is entirely politically motivated (almost all technical arguments are bogus, and the reasonable ones are exaggerated by the fallacy of vivid argument). N3613 has achieved its purpose - static if will never be a part of C++, so from that standpoint it has been successful. However, it is one of the most vitriolic papers I have ever seen within a serious organization, and I hope for its authors' sake they have the decency to not be proud of it in private.This presentation: https://parasol.tamu.edu/people/bs/622-GP/C++14TAMU.pdf He criticizes C99 VLA (slide 24) as being "an abomination" But the surprise comes at the end (slide 57), where he also criticizes... the static if as being "a total abomination". Well, this is D, I told myself. Are those points valid?: static if is a total abomination • Unstructured, can do everything (just like goto) • Complicates static analysis (AST-based tools get hard to write) • Blocks the path for concepts • Specifies how things are done (implementation) • Is three slightly different “ifs” using a common syntax • Redefines the meaning of common notation (such as { ... })Yeah, well, we have many years of experience with "static if" and no apocalypse has yet happened. The proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3329.pdf Bjarne's rebuttal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3613.pdfC++ is adopting D features anyway. The constexpr proposals are looking a lot like CTFE :-)That won't be admitted, although I have reasons to believe is true. C++ intelligentsia seems to have a superiority complex with regard to D, and that's entirely understandable. Andrei
Sep 13 2014
Andrei Alexandrescu:D offers strong evidence that static if is an enormously useful construct.But it's not a complete typing. The Concepts Lite are a more principled and safer solution. (Are Rust templates comparable to first order Concepts Lite?) Bye, bearophile
Sep 13 2014
On 9/13/2014 6:49 PM, Andrei Alexandrescu wrote:"parallel construction" :-)C++ is adopting D features anyway. The constexpr proposals are looking a lot like CTFE :-)That won't be admitted,
Sep 13 2014
On Sunday, 14 September 2014 at 01:48:51 UTC, Andrei Alexandrescu wrote:However, it is one of the most vitriolic papers I have ever seen within a serious organization,I've had the same impressions... -- /Paolo
Sep 14 2014
On Sunday, 14 September 2014 at 01:48:51 UTC, Andrei Alexandrescu wrote:On 9/13/14, 3:25 PM, Walter Bright wrote:To be fair, the way it is implemented right now is a hack, and it is not C++ standard grade definition. Not even remotely close. Trying to implement that in a more rigorous way led me to some "Google have no idea what you are talking about" moment. It is fairly clear so far that I'm either very bad at research, or that approach necessary to handle static if like construct in languages is absolutely unresearched. Relevant link summarizing the whole experience: http://phdcomics.com/comics/archive.php?comicid=1727On 9/13/2014 1:10 PM, eles wrote:D offers strong evidence that static if is an enormously useful construct. I have all respect for Bjarne as language designer, researcher, and engineer, but the evidence suggest he called this wrong. He is right that static if would have derailed work on concepts, because it simply exposes them as missing the point. From that perspective N3613 is entirely politically motivated (almost all technical arguments are bogus, and the reasonable ones are exaggerated by the fallacy of vivid argument).This presentation: https://parasol.tamu.edu/people/bs/622-GP/C++14TAMU.pdf He criticizes C99 VLA (slide 24) as being "an abomination" But the surprise comes at the end (slide 57), where he also criticizes... the static if as being "a total abomination". Well, this is D, I told myself. Are those points valid?: static if is a total abomination • Unstructured, can do everything (just like goto) • Complicates static analysis (AST-based tools get hard to write) • Blocks the path for concepts • Specifies how things are done (implementation) • Is three slightly different “ifs” using a common syntax • Redefines the meaning of common notation (such as { ... })Yeah, well, we have many years of experience with "static if" and no apocalypse has yet happened. The proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3329.pdf Bjarne's rebuttal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3613.pdf
Sep 14 2014
On 9/14/14, 3:42 AM, deadalnix wrote:To be fair, the way it is implemented right now is a hack, and it is not C++ standard grade definition. Not even remotely close.That hasn't been a problem. There are many hacks that have been standardized in C++. Andrei
Sep 14 2014
Andrei Alexandrescu:C++ intelligentsia seems to have a superiority complex with regard to D, and that's entirely understandable.D and C++ compete for a similar programming niche, but C++ is so much widespread compared to D, that it's like comparing a blue whale with an ant. In practice there is no real match and competition. D is not going to replace C++ in the next few years, and probably it will not eat a significant percentage of the C++ pie. So I think it's a good idea to have a little more collaboration between the two language communities. Such "superiority complex" is not going to help any one. Bye, bearophile
Sep 15 2014
On 9/15/14, 11:17 AM, bearophile wrote:Andrei Alexandrescu:Just for fun... Blue whale mass: 190,000 kg on average (Adult) Typical red/black ant mass: 0.003 to 0.005 grams Ratio: 38,000,000,000x Rough estimates for the size of the D community (based on dmd downloads) would place it in the tens of thousands. C++ users would be over 1 million. So...C++ intelligentsia seems to have a superiority complex with regard to D, and that's entirely understandable.D and C++ compete for a similar programming niche, but C++ is so much widespread compared to D, that it's like comparing a blue whale with an ant.In practice there is no real match and competition. D is not going to replace C++ in the next few years, and probably it will not eat a significant percentage of the C++ pie. So I think it's a good idea to have a little more collaboration between the two language communities. Such "superiority complex" is not going to help any one.You may be misunderstanding something. You're telling this to the wrong people. Andrei
Sep 15 2014
On Monday, 15 September 2014 at 18:17:37 UTC, bearophile wrote:Andrei Alexandrescu:The problem is, the C++ community is unwilling to collaborate with anyone else and this attitude is encouraged by Stroustrup.C++ intelligentsia seems to have a superiority complex with regard to D, and that's entirely understandable.D and C++ compete for a similar programming niche, but C++ is so much widespread compared to D, that it's like comparing a blue whale with an ant. In practice there is no real match and competition. D is not going to replace C++ in the next few years, and probably it will not eat a significant percentage of the C++ pie. So I think it's a good idea to have a little more collaboration between the two language communities. Such "superiority complex" is not going to help any one. Bye, bearophile
Sep 29 2014
On Tuesday, 30 September 2014 at 00:02:49 UTC, SomeDude wrote:The problem is, the C++ community is unwilling to collaborate with anyone else and this attitude is encouraged by Stroustrup.What makes you think so ? I'm not telling you are wrong, simply not that familiar with C++ inner circles.
Sep 29 2014
SomeDude:The problem is, the C++ community is unwilling to collaborate with anyone else and this attitude is encouraged by Stroustrup.The C++ language has plenty of warts and unnecessary complexities, but to me the C++ community seems normal, like other languages communities. Usually such communities don't collaborate a lot with other ones (I have seen the Python community collaborate a little with the Julia community, but such collaborations seem the exception). Bye, bearophile
Sep 29 2014
Looks like this made it to reddit: http://www.reddit.com/r/programming/comments/2hsxe2/alexandrescu_speaks_up_on_the_infamous_static_if/
Sep 29 2014
On Tuesday, 30 September 2014 at 06:46:35 UTC, Walter Bright wrote:Looks like this made it to reddit: http://www.reddit.com/r/programming/comments/2hsxe2/alexandrescu_speaks_up_on_the_infamous_static_if/I think the correct counter-attack is simply to write a note showing those cases that concepts lite do not solve, at least not as nicely as static if would have. Eventually with D examples. It will bring audience.
Sep 30 2014
On Tuesday, 30 September 2014 at 07:04:39 UTC, eles wrote:I think the correct counter-attack is simply to write a note showing those cases that concepts lite do not solve, at least not as nicely as static if would have.It is probably not a good idea to bring more attention to it… some might end up agreeing with Stroustrup. "static if" is a troubled construct and too close to macros to be a good language design feature, it is in the same bag as string mixins. "if(constexpr…)" + concepts etc better fit C++.Eventually with D examples. It will bring audience.Yes, this a better idea. Write code examples that compare common C++ patterns to D where D looks cleaner.
Sep 30 2014
On 09/13/2014 10:10 PM, eles wrote:... But the surprise comes at the end (slide 57), where he also criticizes... the static if ... Are those points valid?: ... • Unstructured, can do everything (just like goto) • Complicates static analysis (AST-based tools get hard to write) • Blocks the path for concepts • Specifies how things are done (implementation) • Is three slightly different “ifs” using a common syntax • Redefines the meaning of common notation (such as { ... })In D, { ... } has this other meaning even without static if and I would say similar syntax rather than common syntax and leave out the pointless reference to goto. Otherwise, yes. In exchange you get static if. :o) However, as Peter points out, static if as implemented in DMD currently has some serious issues: static if(!is(typeof(x))) enum y=2; static if(!is(typeof(y))) enum x=1; This code is ambiguous: It could define either x or y. If the two static if's are defined in different modules that import each other, then the order those modules are passed to DMD on the command line can influence which of x or y ends up being defined. The problem is that DMD does not seem to have a coherent way of resolving dependencies. (My own project does not compile with versions of DMD after 2.060, and even with 2.060, I had to move code around randomly. I think it will be easily fixed to compile again only when analysis dependency management is fixed in a good enough way.)
Sep 13 2014
"Timon Gehr" wrote in message news:lv2mgv$qcq$1 digitalmars.com...However, as Peter points out, static if as implemented in DMD currently has some serious issues: static if(!is(typeof(x))) enum y=2; static if(!is(typeof(y))) enum x=1; This code is ambiguous: It could define either x or y.I do acknowledge this is a problem, but I am yet to run into it in actual D code. Most of my static ifs are either inside templates, inside functions, or are being used to bypass version's limitations.
Sep 14 2014
On 9/14/2014 12:35 AM, Daniel Murphy wrote:I do acknowledge this is a problem, but I am yet to run into it in actual D code. Most of my static ifs are either inside templates, inside functions, or are being used to bypass version's limitations.A similar problem once existed in the druntime, which caused a bunch of head-scratching nastiness. The problem was the person who wrote it was trying to make an import context-dependent, i.e. behave differently depending on how it was imported. I replaced the offending logic with straightforward code, but it does expose this dependency problem with static if. The compiler should detect these sorts of things and reject them.
Sep 14 2014
On Sunday, 14 September 2014 at 20:21:51 UTC, Walter Bright wrote:On 9/14/2014 12:35 AM, Daniel Murphy wrote:The compiler should detect these sorts of things and reject them.I agree. Let's not forget that the complication of C and C++ started with exactly such "small and negligible" inconvenients that latter proved more and more difficult to solve...
Sep 14 2014
On Sunday, 14 September 2014 at 20:21:51 UTC, Walter Bright wrote:On 9/14/2014 12:35 AM, Daniel Murphy wrote:If that is really a concern, please consider commenting on http://wiki.dlang.org/DIP31I do acknowledge this is a problem, but I am yet to run into it in actual D code. Most of my static ifs are either inside templates, inside functions, or are being used to bypass version's limitations.A similar problem once existed in the druntime, which caused a bunch of head-scratching nastiness. The problem was the person who wrote it was trying to make an import context-dependent, i.e. behave differently depending on how it was imported. I replaced the offending logic with straightforward code, but it does expose this dependency problem with static if. The compiler should detect these sorts of things and reject them.
Sep 14 2014
On 9/14/2014 2:48 PM, deadalnix wrote:If that is really a concern, please consider commenting on http://wiki.dlang.org/DIP31I haven't thought it through, but the DIP looks like a good idea. It should add the test case in this thread, static if(!is(typeof(x))) enum y=2; static if(!is(typeof(y))) enum x=1; as being something that is detected and rejected by the compiler. Essentially, anything that is order-of-evaluation dependent should be detected and rejected.
Sep 14 2014
On 09/15/2014 12:38 AM, Walter Bright wrote:On 9/14/2014 2:48 PM, deadalnix wrote:(It is furthermore also important that most programs that are not dependent on evaluation order are still accepted.)If that is really a concern, please consider commenting on http://wiki.dlang.org/DIP31I haven't thought it through, but the DIP looks like a good idea. It should add the test case in this thread, static if(!is(typeof(x))) enum y=2; static if(!is(typeof(y))) enum x=1; as being something that is detected and rejected by the compiler. Essentially, anything that is order-of-evaluation dependent should be detected and rejected.
Sep 14 2014
On 09/15/2014 04:53 AM, Timon Gehr wrote:On 09/15/2014 12:38 AM, Walter Bright wrote:To elaborate a little: The following simple test case cannot be accepted using a strategy that alternately analyses AST nodes and poisons symbols that do not occur in certain scopes: enum x = "enum xx = q{int y = 0;};"; struct SS{ mixin(xx); mixin(x); } However, it can be given a unique meaning.On 9/14/2014 2:48 PM, deadalnix wrote:(It is furthermore also important that most programs that are not dependent on evaluation order are still accepted.)If that is really a concern, please consider commenting on http://wiki.dlang.org/DIP31I haven't thought it through, but the DIP looks like a good idea. It should add the test case in this thread, static if(!is(typeof(x))) enum y=2; static if(!is(typeof(y))) enum x=1; as being something that is detected and rejected by the compiler. Essentially, anything that is order-of-evaluation dependent should be detected and rejected.
Sep 14 2014
On Monday, 15 September 2014 at 03:10:08 UTC, Timon Gehr wrote:On 09/15/2014 04:53 AM, Timon Gehr wrote:I remember deadlnix telling quite a lot of nice stories about how this makes in sort of SDC parallelisation problematic :)On 09/15/2014 12:38 AM, Walter Bright wrote:To elaborate a little: The following simple test case cannot be accepted using a strategy that alternately analyses AST nodes and poisons symbols that do not occur in certain scopes: enum x = "enum xx = q{int y = 0;};"; struct SS{ mixin(xx); mixin(x); } However, it can be given a unique meaning.On 9/14/2014 2:48 PM, deadalnix wrote:(It is furthermore also important that most programs that are not dependent on evaluation order are still accepted.)If that is really a concern, please consider commenting on http://wiki.dlang.org/DIP31I haven't thought it through, but the DIP looks like a good idea. It should add the test case in this thread, static if(!is(typeof(x))) enum y=2; static if(!is(typeof(y))) enum x=1; as being something that is detected and rejected by the compiler. Essentially, anything that is order-of-evaluation dependent should be detected and rejected.
Sep 17 2014
On Sunday, 14 September 2014 at 07:35:12 UTC, Daniel Murphy wrote:I do acknowledge this is a problem, but I am yet to run into it in actual D code. Most of my static ifs are either inside templates, inside functions, or are being used to bypass version's limitations.I tend to run into forward referencing issues all the time "declarative" metaprogramming, i.e. when generating some code based on existing symbols and their attributes (e.g. serialization, RPC, …). Manu IIRC also has some related war stories to tell. Granted, it's not the directly the same as two ifs next to each other conflicting (you mostly get dependencies via __traits(allMembers, …) and so on), but whatever forward reference resolution mechanism we choose must be able to handle both the same. David
Sep 14 2014
On Sunday, 14 September 2014 at 22:58:44 UTC, David Nadlinger wrote:I tend to run into forward referencing issues all the time "declarative" metaprogrammingWhoops, a "with"/"when doing" went missing there.
Sep 14 2014
On Sunday, 14 September 2014 at 22:58:44 UTC, David Nadlinger wrote:On Sunday, 14 September 2014 at 07:35:12 UTC, Daniel Murphy wrote:Yes, this is not uncommon way to hit the wall. Separating reflection/generation "stages" into different modules and keeping an eye for cyclic imports seems like a best way to address it right now in my opinion.I do acknowledge this is a problem, but I am yet to run into it in actual D code. Most of my static ifs are either inside templates, inside functions, or are being used to bypass version's limitations.I tend to run into forward referencing issues all the time "declarative" metaprogramming, i.e. when generating some code based on existing symbols and their attributes (e.g. serialization, RPC, …). Manu IIRC also has some related war stories to tell. Granted, it's not the directly the same as two ifs next to each other conflicting (you mostly get dependencies via __traits(allMembers, …) and so on), but whatever forward reference resolution mechanism we choose must be able to handle both the same. David
Sep 17 2014
I can provide first hand experience on taht one, having them implemented in SDC. On Saturday, 13 September 2014 at 20:10:55 UTC, eles wrote:static if is a total abomination • Unstructured, can do everything (just like goto)True !• Complicates static analysis (AST-based tools get hard to write)Very True !• Blocks the path for conceptsI don't think so. The 2 can cohabit.• Specifies how things are done (implementation)I'm not sure what this one mean precisely.• Is three slightly different “ifs” using a common syntaxYes, but i don't think this is an issue.• Redefines the meaning of common notation (such as { ... })The meaning of {} is different depending on the construct it is used with. That's is no different in the case of static if.
Sep 14 2014
On Sunday, 14 September 2014 at 09:42:28 UTC, deadalnix wrote:The way I interpret it is that (for template constraints), they are quite clumsy for specifying preferences between overloads, e.g. void foo(R)(R r) if (isInputRange!R && !isRandomAccessRange!R && !isSomeString!R) void foo(R)(R r) if (isRandomAccessRange!R && !isSomeString!R) void foo(R)(R r) if (isSomeString!R) Would be nice to have something like this instead: void foo(InputRange R)(R r); void foo(RandomAccessRange R)(R r); void foo(SomeString R)(R r); along with a way to specify if one "concept" is more refined than another (either explicitly or implicitly).• Specifies how things are done (implementation)I'm not sure what this one mean precisely.
Sep 14 2014
On Saturday, 13 September 2014 at 20:10:55 UTC, eles wrote:Are those points valid?: static if is a total abomination • Unstructured, can do everything (just like goto) • Complicates static analysis (AST-based tools get hard to write) • Blocks the path for concepts • Specifies how things are done (implementation) • Is three slightly different “ifs” using a common syntax • Redefines the meaning of common notation (such as { ... })The lack of « something like static if » in C++ and his opposition to it (which dates back from many years ago) is what made me search for better languages and discover D. C++ has only half-assed metaprogramming limited to types, and the lack of static if has forced me so many times to rewrite very similar code from one function to another. With D I can have a « function skeleton » and avoid all redundancies with static if. Plus mixins expand enormously on the C preprocessor (although AST macros would be even better). IMHO it's all good for D, full-featured metaprogramming is a killer feature and can save a great amount of time and headaches. The more backwards C++ chooses to remain the faster alternatives will grow.
Sep 14 2014
On 9/13/2014 3:10 PM, eles wrote:This presentation: https://parasol.tamu.edu/people/bs/622-GP/C++14TAMU.pdf He criticizes C99 VLA (slide 24) as being "an abomination" But the surprise comes at the end (slide 57), where he also criticizes... the static if as being "a total abomination". Well, this is D, I told myself. Are those points valid?: static if is a total abomination • Unstructured, can do everything (just like goto) • Complicates static analysis (AST-based tools get hard to write) • Blocks the path for concepts • Specifies how things are done (implementation) • Is three slightly different “ifs” using a common syntax • Redefines the meaning of common notation (such as { ... })Its a downright cute and cuddly abomination to have as opposed to the one that exists in the world of #define and its minions #if/#ifdef/#elif/#if defined()/#else/#endif
Sep 14 2014