Blog series to teach and show off D's metaprogramming by creating a JSON serialiser
Martin Tschierschke
mt at smartdolphin.de
Mon Nov 4 09:30:39 UTC 2019
On Monday, 4 November 2019 at 08:25:11 UTC, Patrick Schluter
wrote:
> On Sunday, 3 November 2019 at 21:35:18 UTC, JN wrote:
>> On Sunday, 3 November 2019 at 08:37:07 UTC, SealabJaster wrote:
>>> On Sunday, 3 November 2019 at 08:35:42 UTC, SealabJaster
>>> wrote:
>>>> On Friday, 1 November 2019 at 21:14:56 UTC, SealabJaster
>>>> wrote:
>>>>> ...
>>>
>>> Sorry, seems it cut out the first half of that reply.
>>>
>>> New posts are out, and I don't want to spam Announce with new
>>> threads, so I'm just replying to this one.
>>>
>>> #1.1
>>> https://bradley.chatha.dev/Home/Blog?post=JsonSerialiser1_1
>>> #2 https://bradley.chatha.dev/Home/Blog?post=JsonSerialiser2
>>
>> "This often seems to confuse people at first, especially those
>> coming from other languages"
>>
>> I think what's confusing people is that enum (short for
>> ENUMERATION) is suddenly used like a constant/alias.
>
> I don't get why it confuses people.
> In all languages I know (C, C++, Java, Pascal, etc..) they are
> used to associate a compile time symbols with some quantities,
> i.e. the definition of constants.
> When an enumeration only consists of 1 value, then the
> enumeration is this value itself.
Yes and no, because the fist case for using enum described at [1]
is something very different:
> This defines a new type X which has values X.A=0, X.B=1, X.C=2:
> enum X { A, B, C } // named enum
[1] https://dlang.org/spec/enum.html
And it might be good to change the docs to point out the very
often taken use case for declaring a singe compile time constant.
More information about the Digitalmars-d-announce
mailing list