What is the difference between enum and shared immutable?

Daniel Kozak kozzi11 at gmail.com
Fri Oct 30 08:24:35 UTC 2020

On Thu, Oct 29, 2020 at 4:13 PM H. S. Teoh via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> But why can't that be treated differently from explicitly writing @safe
> on a declaration?  I mean, yeah, it's easier to implement the compiler
> that way, but ease of implementation shouldn't count against proper
> language design!
> T
> --
> Doubt is a self-fulfilling prophecy.

But what about this:

shared {
    some_ type some_var;
    immutable int x = 1;

There are many ways to define it and last time when I was looking at how
this is implemented in D frontend it was implemented as a bitmask variable
and you have no context from where it comes.
So only way would be to disallow this within lexer which I do not see as a
good options
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20201030/977cf77f/attachment.htm>

More information about the Digitalmars-d-learn mailing list