Sealed classes - would you want them in D?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed May 16 03:12:03 UTC 2018


On Wednesday, May 16, 2018 02:39:22 KingJoffrey via Digitalmars-d wrote:
> On Tuesday, 15 May 2018 at 21:05:10 UTC, Jonathan M Davis wrote:
> > Though if someone expects to be able to just jump into any
> > language and use it without reading up on how it works, they're
> > just shooting themselves in the foot. And surprisingly often,
> > that seems to be how many folks operate.
>
> And that comment is a little unfair don't you think?

Is it? How many programmers just start trying to program in D without
actually reading much of anything about it? We not only have the spec but
multiple books on the language - some of which are available for free - and
yet plenty of programmers (regardless of the language) seem to think that
they can just start programming in a language and only look up stuff when
they run into a problem and yet expect to have that work well without
running into serious problems. Anyone taking that approach is just begging
for trouble. Obviously, not everyone does that, but a suprisingly large
number of programmers seem to. We try to help such folks when they do ask
questions, but plenty of questions that get asked clearly show that the
person asking the question has not studied the language much at all.

> The best clarification I can find, regarding how D treat's
> private, is from this tiny little sentence (from which, I assume,
> the programmer is now meant to understand it's full implications):
>
> "Symbols with private visibility can only be accessed from within
> the same module"
>
> https://dlang.org/spec/attribute.html#visibility_attributes

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



More information about the Digitalmars-d mailing list