March 08, 2023 [Issue 23766] New: Mixin template should support core.attribute:selector | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23766 Issue ID: 23766 Summary: Mixin template should support core.attribute:selector Product: D Version: D2 Hardware: x86_64 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: msnmancini@hotmail.com I understand about not supporting selector for templates. But mixin template should not even be considered template as it only inserts the code where it is. Objective c has a bind boilerplate code while defining the alloc/init, and it can even be simplified by using the following mixin: ```d mixin template ObjectiveCOpCall() { extern(Objective-C) override static typeof(this) alloc() @selector("alloc") extern(Objective-C) override typeof(this) init() @selector("init"); extern(D) final static typeof(this) opCall(){return alloc.init;} } extern(Objective-C): extern class NSObject { static NSObject alloc() @selector("alloc"); NSObject init() @selector("init"); } extern class MTLRenderPassColorDescriptor : NSObject { mixin ObjectiveCOpCall(); } ``` -- |
Copyright © 1999-2021 by the D Language Foundation