[Issue 23766] New: Mixin template should support core.attribute:selector

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 8 11:36:46 UTC 2023


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 at puremagic.com
          Reporter: msnmancini at 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();
}
```

--


More information about the Digitalmars-d-bugs mailing list