Passing private functions to template algorithms
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jun 12 03:55:11 PDT 2016
On 12.06.2016 10:28, Dicebot wrote:
> On 06/07/2016 09:59 PM, Timon Gehr wrote:
>> I think it is obvious that this should work. Visibility checks need to
>> happen during identifier lookup. This lookup is happening in the module
>> where isFileNothrow is visible.
>
> My understanding is that right now template alias argument means
> transparent symbol lookup. It acts as if doesn't access alias symbol in
> template but aliased one directly.
> ...
The lookup accesses the alias and is immediately rewritten to refer to
the aliased symbol. Visibility checks should be applied during the
lookup, but not after the rewrite.
> I agree such semantics are sub-optimal but changing that can break quite
> some existing idioms. Consider this snippet for example:
>
> enum name ( alias sym ) = sym.stringof;
>
> Right now it evaluates to name of passed symbol. If we change lookup
> semantics to be non-transparent, it must always return `sym` for
> consistency.
>
I completely disagree that this would need to happen. E.g.
fullyQualifiedName should work with private symbols just as well as with
public ones.
Maybe this is helpful: https://en.wikipedia.org/wiki/Information_hiding
More information about the Digitalmars-d
mailing list