extern(C++, ns)

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 8 06:05:57 PST 2016


On 2016-01-08 14:50, Walter Bright wrote:

> No:
>
> 1. first "ns.a" looks up "ns". Finds it in the current module, "main.ns".
> 2. Looks "a" up in "main.ns". "a" is not there. Error.
>
> "a()" works because:
>
> 1. Look up "a" in current module. Doesn't find it.
> 2. Look up "a" in import "foo".
>     1. doesn't find it. Look in imported scope "foo.ns". finds it.
> 3. Look up "a" in import "bar".
>     1. doesn't find it. Look in imported scope "bar.ns". Doesn't find it.
>
> Found only one "a" in the imports. We have da winnah!
>
> I think name lookup rules are straightforward in D. I explain them over
> and over, for years, and nobody but me understands them. I find it very
> frustrating.

Yeah, I know, you have explained it several times. Although it doesn't 
always feel intuitive when you're actually writing the code. It's not 
like the above rules are hard to understand, it's just that I don't 
think of the look up rules above when I'm actually writing code.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list