Does D have too many features?
foobar
foo at bar.com
Mon Apr 30 09:32:16 PDT 2012
On Monday, 30 April 2012 at 15:38:41 UTC, simendsjo wrote:
>
> I think struct literals is worse in this regard:
> struct S {
> int a;
> int b;
> }
>
> user code:
> S(1, 2);
>
> The author of S cleans up the struct and changes the order:
> struct S {
> int b;
> int a;
> }
>
> Suddely user code has bugs. I believe the reason named
> parameters hasn't been introduced is because the names becomes
> part of the public interface. Well.. With struct literals, the
> _position_ of the parameters is part of the interface.
Structs provide POD value types and as such MUST include the
position as part of the interface. The memory layout of these
types is used to copy, compare, transmit over the net, etc. If
you want encapsulation you need to at the least to define a ctor
or maybe change to a class.
I'd be very upset if I defined a struct for
serialization/transmitting over the net/etc and changing its
memory _didn't_ cause loud compiler errors.
named parameters are 99% of the time a horrible idea and likely
indicate a design flaw.
More information about the Digitalmars-d
mailing list