[Issue 11946] "need 'this' to access member" when passing field to template parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 29 18:23:36 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11946



--- Comment #26 from Kenji Hara <k.hara.pg at gmail.com> 2014-01-29 18:23:31 PST ---
(In reply to comment #24)
> Some thoughts:
> 
> 1. 'static' in D has come to mean "a context pointer is not supplied". For
> example, in C:
> 
>     void foo() {
>        static int x;
>     }
> 
> x can be accessed without the "context pointer", in this case the stack
> pointer. Static doesn't mean it is unnested or global.

I used the word 'unnested' to represent the equivalent meaning with "a context
pointer is not supplied". So basically I agree with this.

> 2. Alias template arguments are never "passed" to a template in the way that
> arguments are passed to functions. They simply make the symbol in scope in the
> template body.

About the merely visibility of the passed alias parameter, it is correct.
But, instantiated function f!(x).f should have a context to access context-full
symbol 'x'. _Currently_ this is not avoidable.

> 3. Static as an attribute makes no sense in a context where there is no context
> pointer. I.e. declarations at global level, declarations inside global
> templates, etc.

Yes.

> 4. A use of a symbol, where that use does not require a context pointer, should
> not issue an error if a context pointer is not supplied.

Essentially yes. But current compiler does not support the principle, because
of the lack of language feature.

> 5. I don't think we're going to resolve this easily without a lot of careful
> thought.

Definitely yes.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list