cascade operator or nearest equivalent

bearophile bearophileHUGS at lycos.com
Thu Sep 12 12:41:48 PDT 2013


Daniel Davidson:

> I am using Dart for code generation but would like to consider 
> D if I can find a convenient replacement for the following 
> declarative style:

Replacing Dart with D seems quite strange, such two languages 
have so much different usage niches.


>     var dateRange = struct('date_range')
>       ..doc = 'Basic pair of start and end dates'
>       ..unitTest = true
>       ..publicSection = true
>       ..members = [
>         member('start_date')
>         ..type = 'Date',
>         member('end_date')
>         ..type = 'Date',
>       ];

A similar syntax is not allowed in D, but there are two things 
that help for this: the C-style initialization of structs, that 
support field names too, and the with(){} statement.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list