Concerns about using struct initializer in UDA?

Andre Pany via Digitalmars-d digitalmars-d at puremagic.com
Thu May 11 04:36:17 PDT 2017


On Thursday, 11 May 2017 at 10:51:09 UTC, Stefan Koch wrote:
> On Thursday, 11 May 2017 at 10:49:58 UTC, Andre Pany wrote:
>> Hi,
>>
>> I know there are concerns about struct initialization in 
>> method calls but what is about struct initializer in UDA?
>>
>> Scenario: I want to set several UDA values. At the moment I 
>> have to create for each value a structure with exactly 1 
>> field. But it would be quite nice if I could use struct 
>> initialization to group these values:
>>
>> struct Field
>> {
>> 	string location;
>> 	string locationName;
>> }
>>
>> struct Foo
>> {
>> 	@A = {locationName: "B"} int c; // <------------------
>> }
>>
>> void main() {}
>>
>> Of course the syntax is questionable, it is just a proposal.
>> What do you think?
>>
>> Kind regards
>> André
>
> We have that syntax already.

I do not understand. Should the syntax I have written already 
work as I expect or do you mean my proposal is not possible as 
the syntax is ambiguous?

Kind regards
André


More information about the Digitalmars-d mailing list