Sealed classes - would you want them in D?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed May 16 04:25:40 UTC 2018


On Wednesday, May 16, 2018 03:36:39 KingJoffrey via Digitalmars-d wrote:
> On Wednesday, 16 May 2018 at 03:12:03 UTC, Jonathan M Davis wrote:
> > It specifies what private does quite accurately. If you want
> > something that's trying to point out how you might
> > misunderstand the spec or what problems you might run into,
> > you'll need to read something like Ali's book. The spec is
> > telling you how the language works, not trying to tell you how
> > you might misunderstand it or what misakes you might make. And
> > the information it gives there is quite accurate and complete.
> > Honestly, I would have thought that knowing that private is
> > private to the module would be plenty to understand what that
> > then means for structs or classes, but everyone thinks
> > differently and absorbs or misses different pieces of
> > information. But ultimately, anyone who doesn't understand
> > something is free to ask in places like D.Learn or
> > stackoverflow.
> >
> > - Jonathan M Davis
>
> To suggest that "Symbols with private visibility can only be
> accessed from within the same module" - is all you need to know
> (if you're lucky to find the needle in the haystack), is kinda
> elitist.
>
> People expect norms to be the norm. That's entirely reasonable.
>
> If I see a STOP sign while I'm driving, I expect it means STOP,
> not 'STOP..if.."
>
> If I see private, I expect it means private, not 'private..if'.

I don't see why it would be elitist to expect folks to read the spec and
assume that it means what it says. It's always a risk that someone is going
to assume that a language that they're learning works the same way as a
language that they know even if it doesn't, but anyone learning a new
language needs to take into account the fact that every language works
differently, and you need to read up on how the language you're learning
actually works if you want to avoid misunderstanding stuff. private is far
from the only feature in D that doesn't work quite like it does in other
languages.

> The language reference could, and should do better.

I think that really what you want is something that's geared more towards
teaching the language. The ways that the language spec needs to be improved
really revolve around making it a proper spec, which means making it far
more precise, not making it more amenable to folks reading it in order to
learn the language. But unfortunately, what we have right now is kind of in
the middle. It's not precise enough to really be a proper spec, and it's
generally terse enough that it's harder to use it as a learning resource
(though it usually has the necessary information in it).

- Jonathan M Davis



More information about the Digitalmars-d mailing list