[dmd-beta] dmd 2.064 beta take 2

Leandro Lucarella luca at llucax.com.ar
Wed May 15 13:33:45 PDT 2013


Andrei Alexandrescu, el 15 de May a las 15:07 me escribiste:
> On 5/15/13 3:02 PM, Walter Bright wrote:
> >I believe it was disallowed in earlier D2 versions. If I saw such code
> >in a project, I'd find it awfully suspect, not sensible.
> 
> On the contrary, examples abound. Consider:
> 
> class Image {
>     const double scalingFactor = 1.0; // no scaling
>     this(double sf) {
>         scalingFactor = sf;
>         ...
>     }
>     ...
> }
> 
> What is suspect about this? I have about five others without even
> needing to think that hard.

I think it make more sense to put the default in the constructor
argument instead of in the member variable declaration. In that case is
pretty clear, but if the member declaration is far from the constructor,
one could easily assume scalingFactor is always 1.0.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Esta desenchufada la internet de ese televisor?
	-- Osvaldo Lucarella


More information about the dmd-beta mailing list