Compiler bug ?
Maxim Fomin
maxim at maxim-fomin.ru
Fri May 17 11:31:13 PDT 2013
On Friday, 17 May 2013 at 17:08:31 UTC, Jonathan M Davis wrote:
> On Friday, May 17, 2013 11:59:38 1100110 wrote:
>> On 05/17/2013 09:35 AM, Maxim Fomin wrote:
>> > If it alwalys a bad idea, compiler should not accept such
>> > code.
>>
>> It is not the D way to forbid you from shooting yourself in
>> the foot.
>>
>> goto, catch(Throwable th), there are plenty more examples.
>
> D will stop you from shooting yourself in the foot if it can do
> so in a way
> that doesn't actually limit you, and it does do quite a few
> things to make it
> harder to shoot yourself in the foot, but it certainly doesn't
> ultimately stop
> you from doing so. However, if it _never_ makes sense to
> declare a variable
> beginning with two underscores, I don't know why the compiler
> wouldn't forbid
> it other than the fact that it probably inserts such variables
> prior to when
> it would do the semantic analysis to check whether variables
> started with
> underscores, in which case, catching the user's variables that
> start with two
> underscores while permitting the compiler's variables could get
> tricky.
>
> - Jonathan M Davis
The only scenario when __identifiers are needed which came to my
mind is case when working with C or os implementation. Low-level
implementation supposed to use '__' namespace because of practice
encouraged by ISO C and other docs to reserve space for user and
system specific identifiers. Probably double leading underscores
should be restricted to extern declarations.
More information about the Digitalmars-d-learn
mailing list