Understanding Safety of Function Pointers vs. Addresses of Functions

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 15 04:44:59 PDT 2015


On Tuesday, 14 July 2015 at 17:24:41 UTC, anonymous wrote:
> This fails with "Error: None of the overloads of 'cos' are 
> callable using argument types (int[])".
>
> The problem is that template mixins cannot add to existing 
> overload sets. The spec says: "If the name of a declaration in 
> a mixin is the same as a declaration in the surrounding scope, 
> the surrounding declaration overrides the mixin one" [1]. That 
> means, the `cos` from `alias cos = std.math.cos;` completely 
> overrides the one from `mixin t!();`. I guess this is a measure 
> against function hijacking again.
>
> I'm not sure if it's supposed to work like it does when the 
> alias is removed, two implicitly imported/generated symbols 
> forming an overload set. But I can't immediately see a problem 
> with it either.
>
> [1] http://dlang.org/template-mixin.html - see "Mixin Scope"



Now - is there a way to rewrite my code without mixins?


More information about the Digitalmars-d-learn mailing list