Ben said:
I would like to apologize for that. I can see how that might be construed
as an insult, I don't wish to insult you, and I hope you will forgive me.
Apology accepted...thank you.
Please understand as well, that your opinion is the one that is exclusive.
You are supporting the view that "internal" is a good enough replacement for
"friend" for everyone, that the restriction is ok in all circumstances.
That strikes me as far more dismissive than my opinion (shared with the OP)
that "friend" behavior is needed in certain circumstances, examples
provided, with no need to remove the existing "internal" access layer.
I'm sorry if my replies made it sound like I felt that "internal" was
exactly equivalent to "friend". I do think that it's obviously not. it
just seemed to me that in this case, it seems like a reasonable
alternative for the stated goal.
I'm not exactly sure what I wrote that wound up sounding like I was
saying "internal" works for everyone in every situation, but whatever I
wrote that came across like that, it wasn't my intent. Sorry for any
confusion.
[...]
I'm not saying that there is no place for the "internal" keyword, or at
least I don't mean to. What I'm saying is that it is a poor substitute for
"friend". C++ provides both, through the concept of incomplete types and
use of non-public header files. It would be quite useful for .NET to as
well. "internal" is far too broad *for these applications*. There are
other circumstances where it is perfect.
Would you really be happy if each of the reusable blocks in the BCL was in a
separate assembly, requiring a separate DLL file to be located and loaded
from the file system for each, requiring separate per-assembly metadata for
each, preventing string folding, etc?
No, that wouldn't make me happy. But it seems to me that "internal",
like "friend", is something to be used sparingly. One hopes that the
issue wouldn't cause too many different assemblies to be required; many
components should be able to be implemented without the use of
"internal" or similar anyway (and besides, there are already specific
examples under the System namespace of components that need to be
referenced explicitly).
I do think it's a bit of a kludge that "internal" is tied to the
assembly. But given that it is, I'm not sure I see any truly huge
problems with the overlap. Optimal? I agree, it's not. But I don't
think it's a fatal flaw either.
Even better would be a .NET design change, possibly impractical at this
point, in which multiple assemblies could be linked statically into a
single DLL. I've always felt that it's somewhat limiting for .NET to
not have a way to combine compiled components into a single DLL or EXE
(and of course, if I'm mistaken about there not being a way -- I haven't
found one yet, but that doesn't mean it doesn't exist -- then obviously
that'd be a way to allow the use of "internal" without having a huge DLL
explosion
).
I think we are agreed on this: that the BCL uses "internal" inappropriately.
Yes, I do agree. Much as "friend" is often misused, so too is "internal".
Ironically, as much as people like to debate what language features
should or should not exist, IMHO the language really isn't that
important. Languages can be very nice tools, but in the end no matter
what the language provides or does not provide, there's no substitute
for a programmer who can design simple, workable code.
The fact is, with sufficient discipline, one can accomplish basically
all of the same things a high-level language like C++ or C# offers using
just plain old assembly. And one still needs some level of discipline
to write good C++ or C# code, even with all of the support and
constraints each language offers.
In this particular case, what C# offers is "internal", and I think that
used sparingly as it should be, it shouldn't lead to a great deal of
inefficiency in the form of excessive DLLs.
Pete