Matter of style, and cast()

2013-08-05 Thread bearophile
Some small style rules for D user code: 1) All variables and functions arguments should be immutable/const (or enum), unless they have to mutate (or there is some other problem in Phobos, in the D type system, or in your other code). 2) The code should contain as few cast() as possible. [*]

Re: Matter of style, and cast()

2013-08-05 Thread Joseph Rushton Wakeling
On 08/05/2013 03:01 PM, bearophile wrote: 2) The code should contain as few cast() as possible. [*] What about to!() ... ? Is it possible to gain the performance of cast() while using to!() ... ? 4) for/foreach/while loops are not evil, but it's better to use map/filter/zip where possible

Re: Matter of style, and cast()

2013-08-05 Thread Bosak
On Monday, 5 August 2013 at 13:01:19 UTC, bearophile wrote: Some small style rules for D user code: 1) All variables and functions arguments should be immutable/const (or enum), unless they have to mutate (or there is some other problem in Phobos, in the D type system, or in your other

Re: Matter of style, and cast()

2013-08-05 Thread Bosak
I made a markdown gist for the above module import tips: https://gist.github.com/nikibobi/6156492

Re: Matter of style, and cast()

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 03:01:18PM +0200, bearophile wrote: Some small style rules for D user code: [...] Note that in git HEAD, importing of packages as modules has been implemented via package.d: import my.path.module; will now also work with: /my /my/path

Re: Matter of style, and cast()

2013-08-05 Thread Jonathan M Davis
On Monday, August 05, 2013 15:46:13 Joseph Rushton Wakeling wrote: On 08/05/2013 03:01 PM, bearophile wrote: 2) The code should contain as few cast() as possible. [*] What about to!() ... ? Is it possible to gain the performance of cast() while using to!() ... ? That depends. In general,