On Saturday, 16 June 2018 at 23:33:13 UTC, Jonathan M Davis wrote:
On Saturday, June 16, 2018 22:59:24 DigitalDesigns via
Digitalmars-d wrote:
On Saturday, 16 June 2018 at 06:47:59 UTC, Jonathan M Davis
wrote:
> On Saturday, June 16, 2018 06:08:17 DigitalDesigns via
>
> Digitalmars-d wrote:
>> When an identifier starts with __, allMembers does not
>> return it. This is very bad behavior! It can silently
>> create huge problems if the programmer is not aware of the
>> bug.
>>
>> Instead, if you want to keep the current behavior at least
>> create an error or warning rather than silently create a
>> bug to waste the users time tracking it down.
>
> I would point out that identifiers that start with two
> underscores are supposed to be reserved for the compiler.
> Declaring them yourself is begging for trouble in general.
>
> - Jonathan M Davis
So, you are saying that it's ok to beat me over the head and
cause me trouble simply because I used __? Seriously? I
thought D was all about making the programmers life easier and
not more difficult! Thanks for letting me know! I guess it's
time to go back to C#.
There's no need to be melodramatic. All I'm saying is that
identifiers starting with __ are reserved by the language -
just like they are in many C-derived languages (I would expect
them to be reserved in C# as well, though I don't know for sure
if they are). Whether __traits stuff should ignore such
attributes, I don't know (I wouldn't have expected them to be
ignored, and that does seem weird), but either way, if you have
any variable names that start with two underscores (be they
member variables or local variables or whatever), you're
potentially declaring variables that are in conflict with stuff
that druntime or the compiler itself declare, and you risk bugs
by doing so. Even if __traits shouldn't just ignore those
identifiers, you shouldn't be declaring any variables that
start with two underscores. If you didn't know that before,
then I'm sorry, but the spec mentions it, and now you know.
https://dlang.org/spec/lex.html#identifiers
- Jonathan M Davis
If this was a sane language constraint then any identifiers
starting with __ that were not reserved would at least give a
warning but particularly give an error! Not fail silently and
break code in ways that cannot be determined otherwise. It's bad
enough that the whole template system cannot be properly debugged
but to silently ignore user identities that start with __ just
because is ignorant, and it's not being melodramatic.
I've seen you state several times that D does certain things to
"protect" the user... and now you are justifying it attacking the
user. You can't have it both ways, which is it?
__ is not an uncommon identifier prefix and to reserve it then
have code break in ways that are nearly undetectable and could
cause major bugs in complex programs is not sane. How about
reserve a special character for special identifiers and do a full
rename on the master branch and simply do away with the arbitrary
__ constraint?
There are correct ways to solve the problem and incorrect.
Justifying incorrect ways when they are clearly incorrect is not
sane(but it is typical practice).