[Issue 1182] Mixins scope

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 12 11:58:51 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=1182

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                URL|                            |d
                 CC|                            |razvan.nitu1305 at gmail.com
         Resolution|---                         |WONTFIX

--- Comment #7 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Marcin Kuszczak from comment #4)
> First: How does it work? There are two policy symbols in template 
> (overloaded functions). Why 'getter property' is choosen? How to choose 
> setter?
> 
Because the overload that does not take any parameters is called. If you would
call the other it would be an ambiguity error (as it should).

> Second: That's solution far from good. Imagine you have e.g. 10 symbols 
> inserted by mixin (I work with such a case.).
You can use metaprogramming to generate the aliases.

>What's more mixins are 
> inserted into many inherited classes. You need to alias all symbols 
> inside mixin template in every inherited class.
>
You would most likely get errors regarding overriding.

> Third: Would be also great to implement anchored types (#1120). It would 
>   depreciate this use-case for mixins.
> 
> I request to leave that enhancement open. Simply enhancing rule of 
> inserting anonymous mixin into scope for function names *AND* their 
> arguments would solve problem cleanly.

That will probably never happen. That would break code and it would make the
mixin model inconsistent with the import one and we don't want that. This
design has served us well and there is no reason to change it, since there are
workarounds for all the situations stated in the enhancement request.

Closing as WONTFIX.

--


More information about the Digitalmars-d-bugs mailing list