DIP 1007 - keywords as identifiers with an escape symbol - feedback

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 21 20:11:54 PST 2016


On Mon, 19 Dec 2016 09:58:28 +0000, default0 wrote:
> On Monday, 19 December 2016 at 08:30:07 UTC, Stefan Koch wrote:
>> If you are prepending # you might as well prepend _
> 
> That doesn't solve the complications this introduces if you want to
> serialize to/from members with these names, as seen in the Examples
> section of the DIP.

Sure, but then we could argue that there should be a way to make any 
sequence of characters an identifier. There are systems that expect 
serialized field names with hyphens, for instance. Or if I'm writing code 
to interoperate with a Cherokee system, I might need to produce JSON with 
a field "ᏗᏍᏚᏗ". (Which is perfectly valid in C# but not in D.)

Jsonizer does this the only way you can: you can use an attribute to 
specify the serialized name for a field.

While we're talking about this, this proposal breaks any string mixin 
that mixes in an identifier detected with reflection. Address that 
problem and your proposal just allows identifiers to contain a leading #. 
There are usually ways around using string mixins, but we haven't even 
proposed starting a deprecation process for them.


More information about the Digitalmars-d mailing list