[Issue 2646] Named mixins and member functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 10 09:54:45 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=2646
RazvanN <razvan.nitu1305 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |razvan.nitu1305 at gmail.com
Resolution|--- |INVALID
--- Comment #3 from RazvanN <razvan.nitu1305 at gmail.com> ---
Mixin templates are evaluated in the context of the instantiation scope. It
doesn't matter if a name is given to it or not. For example:
template Signal()
{
void connect() {};
}
class CheckBox
{
mixin Signal toggled;
}
void main()
{
auto a = new CheckBox();
a.connect();
}
This code compiles successfully. You don't have to call `a.toggled.connect`.
This is possible because connect is inserted in the scope of CheckBox (e.g. in
the overload set of that scope level).
Changing this would make mixing functions very difficult to work with.
Closing as invalid.
--
More information about the Digitalmars-d-bugs
mailing list