www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - More from C++ Now 2014

reply "bearophile" <bearophileHUGS lycos.com> writes:
Some more slides pack from "C++ Now 2014":

"Undefined Behavior in C++; what is it, and why should I care":
https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/Undefined-Behavior.pdf?raw=true
This reminds us to remove as much undefined behavior as possible 
from D.

"Mach7: The Design and Evolution of a Pattern Matching Library 
for C++", by Bjarne Stroustrup and others:
https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/open-pattern-matching.pdf?raw=true
This could be a start point to add pattern matching in D, or to 
discuss. Pattern matching requires lot of compiler support and 
some specific syntax.

"Iterators May Stay":
https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/CppNow2014Ranges.pdf?raw=true
This looks like an answer to the "Iterators must go" talk. There 
are many comments about D ranges and some slides about Phobos.

"Ownership of Memory in C++":
https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/ownership_of_memory.pdf?raw=true
This reminds us to not use linked lists. Arrays or arrays of 
smart pointers are good.

Why aren't Reddit people discussing on each of those? :-)

Bye,
bearophile
May 18 2014
next sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 05/18/2014 11:03 AM, bearophile wrote:

 Some more slides pack from "C++ Now 2014":
For those of us who are in the Bay Area, we will have a trip report: http://www.meetup.com/SFBay-Association-of-C-C-Users/events/179180452/ Ali
May 18 2014
prev sibling next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
 "Undefined Behavior in C++; what is it, and why should I care":
 https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/Undefined-Behavior.pdf?raw=true
 This reminds us to remove as much undefined behavior as 
 possible from D.
Fixing some of those problems will break some D code. An example from the slides pack: void main() { import std.stdio; auto arr = [0, 2, 4, 6, 8]; int i = 1; writeln(i + arr[++i] + arr[i++]); } It gives different results in dmd and ldc2: ...>dmd -wi -run temp.d 9 ...>ldmd2 -wi -run temp.d 10 Hopefully no one writes code like that, but this situation can't be accepted in a language that tries to be safer and better than C/C++. Bye, bearophile
May 18 2014
parent reply "Namespace" <rswhite4 googlemail.com> writes:
On Sunday, 18 May 2014 at 22:29:04 UTC, bearophile wrote:
 "Undefined Behavior in C++; what is it, and why should I care":
 https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/Undefined-Behavior.pdf?raw=true
 This reminds us to remove as much undefined behavior as 
 possible from D.
Fixing some of those problems will break some D code. An example from the slides pack: void main() { import std.stdio; auto arr = [0, 2, 4, 6, 8]; int i = 1; writeln(i + arr[++i] + arr[i++]); } It gives different results in dmd and ldc2: ...>dmd -wi -run temp.d 9 ...>ldmd2 -wi -run temp.d 10 Hopefully no one writes code like that, but this situation can't be accepted in a language that tries to be safer and better than C/C++. Bye, bearophile
dmd is right, so ldc has probably a bug. i is 1 ++i is 2 -> arr[2] is 4 i++ is still 2 -> arr[2] is 4 1 + 4 + 4 = 9
May 19 2014
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Namespace:

 dmd is right, so ldc has probably a bug.
I think D specs don't yet require a defined behaviour for that code, so I think both outputs are correct. Bye, bearophile
May 19 2014
prev sibling parent reply "qznc" <qznc web.de> writes:
On Monday, 19 May 2014 at 08:20:54 UTC, Namespace wrote:
 On Sunday, 18 May 2014 at 22:29:04 UTC, bearophile wrote:
 "Undefined Behavior in C++; what is it, and why should I 
 care":
 https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/Undefined-Behavior.pdf?raw=true
 This reminds us to remove as much undefined behavior as 
 possible from D.
Fixing some of those problems will break some D code. An example from the slides pack: void main() { import std.stdio; auto arr = [0, 2, 4, 6, 8]; int i = 1; writeln(i + arr[++i] + arr[i++]); }
dmd is right, so ldc has probably a bug. i is 1 ++i is 2 -> arr[2] is 4 i++ is still 2 -> arr[2] is 4 1 + 4 + 4 = 9
Addition does not imply an order in D, does it? So, the following lines should be equivalent: writeln(i + arr[++i] + arr[i++]); writeln(arr[++i] + i + arr[i++]); writeln(arr[i++] + i + arr[++i]); writeln(i + arr[i++] + arr[++i]); Your reasoning step "is still 2" is inapplicable when there is no order.
May 19 2014
parent "Joakim" <dlang joakim.airpost.net> writes:
On Monday, 19 May 2014 at 09:26:23 UTC, qznc wrote:
 On Monday, 19 May 2014 at 08:20:54 UTC, Namespace wrote:
 On Sunday, 18 May 2014 at 22:29:04 UTC, bearophile wrote:
 "Undefined Behavior in C++; what is it, and why should I 
 care":
 https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/Undefined-Behavior.pdf?raw=true
 This reminds us to remove as much undefined behavior as 
 possible from D.
Fixing some of those problems will break some D code. An example from the slides pack: void main() { import std.stdio; auto arr = [0, 2, 4, 6, 8]; int i = 1; writeln(i + arr[++i] + arr[i++]); }
dmd is right, so ldc has probably a bug. i is 1 ++i is 2 -> arr[2] is 4 i++ is still 2 -> arr[2] is 4 1 + 4 + 4 = 9
Addition does not imply an order in D, does it? So, the following lines should be equivalent: writeln(i + arr[++i] + arr[i++]); writeln(arr[++i] + i + arr[i++]); writeln(arr[i++] + i + arr[++i]); writeln(i + arr[i++] + arr[++i]); Your reasoning step "is still 2" is inapplicable when there is no order.
Actually, he got that part right. i++ will always be 2, as it's only incremented after the statement is done. It took me a minute to realize how the ldc result was even possible: it's because the result depends on whether the pre-increment ++i is done before the entire statement is evaluated, so both i and ++i are 2, or between evaluating i and arr[++i], so i is 1 and ++i is 2. dmd and ldc apparently do the pre-increment at different times, hence undefined behavior.
May 19 2014
prev sibling parent "Paulo Pinto" <pjmlp progtools.org> writes:
On Sunday, 18 May 2014 at 18:03:26 UTC, bearophile wrote:
 Some more slides pack from "C++ Now 2014":

 "Undefined Behavior in C++; what is it, and why should I care":
 https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/Undefined-Behavior.pdf?raw=true
 This reminds us to remove as much undefined behavior as 
 possible from D.

 "Mach7: The Design and Evolution of a Pattern Matching Library 
 for C++", by Bjarne Stroustrup and others:
 https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/open-pattern-matching.pdf?raw=true
 This could be a start point to add pattern matching in D, or to 
 discuss. Pattern matching requires lot of compiler support and 
 some specific syntax.

 "Iterators May Stay":
 https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/CppNow2014Ranges.pdf?raw=true
 This looks like an answer to the "Iterators must go" talk. 
 There are many comments about D ranges and some slides about 
 Phobos.

 "Ownership of Memory in C++":
 https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/ownership_of_memory.pdf?raw=true
 This reminds us to not use linked lists. Arrays or arrays of 
 smart pointers are good.

 Why aren't Reddit people discussing on each of those? :-)

 Bye,
 bearophile
Two another interesting ones are My Thoughts on Large Code Base Change Ripple Management in C++ https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/change_ripple.pdf?raw=true Keynote: Beware of C++ https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/Josuttis_C++Now_140515_handouts.pdf?raw=true As they highlighting the issues C++ complexity has vs other languages, and the corresponding impact in the community. -- Paulo
May 19 2014