Identifier resolution, the great implementation defined mess.

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 23 13:56:56 PDT 2014


On Tuesday, 23 September 2014 at 19:04:55 UTC, Marco Leise wrote:
> Of course, but
>
> void foo(int x)
> {
> 	int y;
> }
>
> appears to the uninitiated as two variables that will only be
> visible inside of foo. The notion of a sourrounding parameter
> scope only comes up when you dig deep into the language. It
> is almost safe to say, without reading the specs or the
> compiler source one wouldn't know. (I didn't :) )
> 

It is obvious when you think about it. Consider contract for
instance.

> Now that I understand that the parameter scope exists I
> understand how the lookup happens.
> I could say the same about the famous JavaScript WAT video.
> Once you understand all the language rules it becomes sane.
> That is exactly what a WAT is about: It is a logical
> consequence of some hidden context inside the language that
> yields totally unexpected results in innocent looking code.

Yes, there is obviously a reason. Nobody explicitly decided that
these construct would yield completely idiotic results. But they
do.


More information about the Digitalmars-d mailing list