www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Article series about patterns & idioms in D

reply Benjamin Thaut <code benjamin-thaut.de> writes:
I started a small article series on D specific patterns & idioms on my 
blog. I'm going to add more over time and hope that there are at least 
some in there which are not already known to everyone.

You can find them here: http://3d.benjamin-thaut.de/?cat=17

Currently there are two:

1) D implict conversion idiom: http://3d.benjamin-thaut.de/?p=90
2) D templated interface idiom: http://3d.benjamin-thaut.de/?p=94

Feedback is welcome.

Kind Regards
Benjamin Thaut
Jul 11 2013
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 7/11/13 11:53 PM, Benjamin Thaut wrote:
 I started a small article series on D specific patterns & idioms on my
 blog. I'm going to add more over time and hope that there are at least
 some in there which are not already known to everyone.

 You can find them here: http://3d.benjamin-thaut.de/?cat=17

 Currently there are two:

 1) D implict conversion idiom: http://3d.benjamin-thaut.de/?p=90
 2) D templated interface idiom: http://3d.benjamin-thaut.de/?p=94

 Feedback is welcome.

 Kind Regards
 Benjamin Thaut
Well you have a typo in the first title... Andrei
Jul 12 2013
parent reply Walter Bright <newshound2 digitalmars.com> writes:
I think it's a nice blog and encourage you to do more!

On 7/12/2013 12:34 AM, Andrei Alexandrescu wrote:
 1) D implict conversion idiom: http://3d.benjamin-thaut.de/?p=90
Well you have a typo in the first title...
The same misspelling occurs repeatedly in the article, so it's not a typo. "implicit" also, buildin => builtin "D strives to prevent implict conversion between user defined types at all costs." I don't think this is true. Implicit conversions are very useful. What D prevents are implicit conversions that can result in data loss, such as integer truncation.
Jul 12 2013
parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
 "D strives to prevent implict conversion between user defined types at
 all costs."

 I don't think this is true. Implicit conversions are very useful. What D
 prevents are implicit conversions that can result in data loss, such as
 integer truncation.
I did talk about implict conversions between user defined types. D does not have implict construction, or implict casting like C++ does. I did not talk about builtin types. -- Kind Regards Benjamin Thaut
Jul 12 2013
next sibling parent reply "Tobias Pankrath" <tobias pankrath.net> writes:
On Friday, 12 July 2013 at 09:42:28 UTC, Benjamin Thaut wrote:
 "D strives to prevent implict conversion between user defined 
 types at
 all costs."

 I don't think this is true. Implicit conversions are very 
 useful. What D
 prevents are implicit conversions that can result in data 
 loss, such as
 integer truncation.
I did talk about implict conversions between user defined types. D does not have implict construction, or implict casting like C++ does. I did not talk about builtin types.
What's about alias this?
Jul 12 2013
parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 12.07.2013 17:12, schrieb Tobias Pankrath:
 On Friday, 12 July 2013 at 09:42:28 UTC, Benjamin Thaut wrote:
 "D strives to prevent implict conversion between user defined types at
 all costs."

 I don't think this is true. Implicit conversions are very useful. What D
 prevents are implicit conversions that can result in data loss, such as
 integer truncation.
I did talk about implict conversions between user defined types. D does not have implict construction, or implict casting like C++ does. I did not talk about builtin types.
What's about alias this?
Did you even read the article? -- Kind Regards Benjamin Thaut
Jul 12 2013
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 7/12/2013 2:42 AM, Benjamin Thaut wrote:
 "D strives to prevent implict conversion between user defined types at
 all costs."

 I don't think this is true. Implicit conversions are very useful. What D
 prevents are implicit conversions that can result in data loss, such as
 integer truncation.
I did talk about implict conversions between user defined types. D does not have implict construction, or implict casting like C++ does.
"alias this" is used for implicit casting. BTW, it's implicit. There's an 'i' there!
 I did not talk about builtin types.
Ok - but I think it would be clearer if the statement added "for user defined types".
Jul 12 2013
parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 12.07.2013 21:00, schrieb Walter Bright:
 On 7/12/2013 2:42 AM, Benjamin Thaut wrote:
 "D strives to prevent implicit conversion between user defined types at
 all costs."
Ok - but I think it would be clearer if the statement added "for user defined types".
For me there is already a "between user defined types" in the following sentence: "D strives to prevent implicit conversions between user defined types at all costs." Is that not clear enough?
Jul 12 2013
parent Walter Bright <newshound2 digitalmars.com> writes:
On 7/12/2013 12:22 PM, Benjamin Thaut wrote:
 Am 12.07.2013 21:00, schrieb Walter Bright:
 On 7/12/2013 2:42 AM, Benjamin Thaut wrote:
 "D strives to prevent implicit conversion between user defined types at
 all costs."
Ok - but I think it would be clearer if the statement added "for user defined types".
For me there is already a "between user defined types" in the following sentence: "D strives to prevent implicit conversions between user defined types at all costs." Is that not clear enough?
It is. I was commenting from memory rather than re-reading it. My mistake.
Jul 12 2013
prev sibling next sibling parent reply Ary Borenszweig <ary esperanto.org.ar> writes:
On 7/12/13 3:53 AM, Benjamin Thaut wrote:
 I started a small article series on D specific patterns & idioms on my
 blog. I'm going to add more over time and hope that there are at least
 some in there which are not already known to everyone.

 You can find them here: http://3d.benjamin-thaut.de/?cat=17

 Currently there are two:

 1) D implict conversion idiom: http://3d.benjamin-thaut.de/?p=90
 2) D templated interface idiom: http://3d.benjamin-thaut.de/?p=94

 Feedback is welcome.

 Kind Regards
 Benjamin Thaut
This sentence worries me a bit: "The code shown above has been tested with dmd 2.063.2" It seems like every minor release of D works different than previous ones. Is that true? Isn't it enough to say "D2"? Can something be done to prevent this?
Jul 12 2013
next sibling parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 12.07.2013 15:26, schrieb Ary Borenszweig:
 On 7/12/13 3:53 AM, Benjamin Thaut wrote:
 I started a small article series on D specific patterns & idioms on my
 blog. I'm going to add more over time and hope that there are at least
 some in there which are not already known to everyone.

 You can find them here: http://3d.benjamin-thaut.de/?cat=17

 Currently there are two:

 1) D implict conversion idiom: http://3d.benjamin-thaut.de/?p=90
 2) D templated interface idiom: http://3d.benjamin-thaut.de/?p=94

 Feedback is welcome.

 Kind Regards
 Benjamin Thaut
This sentence worries me a bit: "The code shown above has been tested with dmd 2.063.2" It seems like every minor release of D works different than previous ones. Is that true? Isn't it enough to say "D2"? Can something be done to prevent this?
The shown code should work all versions of D 2.0 since 2.053 (I'm using it since then). I only mentioned the version of the dmd compiler, because I previously had issues with some of my articles where someone would say "but that statement is not true, it works with the current version of dmd". Kind Regards Benjamin Thaut -- Kind Regards Benjamin Thaut
Jul 12 2013
prev sibling next sibling parent "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Friday, 12 July 2013 at 13:26:21 UTC, Ary Borenszweig wrote:
 This sentence worries me a bit:

 "The code shown above has been tested with dmd 2.063.2"

 It seems like every minor release of D works different than 
 previous ones. Is that true? Isn't it enough to say "D2"? Can 
 something be done to prevent this?
D is still in the alpha phase of development, so things are still likely to change and break regularly. There's not much that can be done other than what's already being done, i.e. just try to implement everything and fix the major bugs as fast as possible. There's no silver bullet.
Jul 12 2013
prev sibling parent "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
This statement kind of worries me:

 It seems like every minor release of D works different than 
 previous ones.
Why would you release a version if it wasn't different from the previous? It would be nice if one could give the oldest known working compiler, but there are still changes to old behavior which means some code would have more specific compiler versions needed. Work is being done, but the issue will exist for some time so process to make it less painful is being put in place.
Jul 12 2013
prev sibling parent reply "Jakob Ovrum" <jakobovrum gmail.com> writes:
On Friday, 12 July 2013 at 06:53:48 UTC, Benjamin Thaut wrote:
 Feedback is welcome.
One of the article says that only one AliasThis is allowed per type, which is only half the truth. Multiple AliasThis are meant to be allowed by the language but has not been implemented.
Jul 13 2013
parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 13.07.2013 13:10, schrieb Jakob Ovrum:
 On Friday, 12 July 2013 at 06:53:48 UTC, Benjamin Thaut wrote:
 Feedback is welcome.
One of the article says that only one AliasThis is allowed per type, which is only half the truth. Multiple AliasThis are meant to be allowed by the language but has not been implemented.
Thanks for the information, didn't know that. Still I like to only advertise things that are already working. Kind Regards Benjamin Thaut
Jul 13 2013