On Saturday, 15 October 2022 at 01:48:15 UTC, kdevel wrote:
Is this consistent?
I think all the compilers should error on expressions like
`Type.nonStaticMethod` and instead there should be a new
__traits dedicated to that, especially because `this` is not a
formal parameter.
On Saturday, 15 October 2022 at 01:48:15 UTC, kdevel wrote:
$ dmd -unittest -main -run ini
ini.d(6): Error: non-constant expression `& bar`
ini.d(7): Error: non-constant expression `& bar`
```
Is this consistent?
I can attest to consistency using ldc. Each of the following
prevent function ad
On Saturday, 15 October 2022 at 00:31:47 UTC, Iain Buclaw wrote:
```
auto funcptr (alias method) ()
{
return &method;
}
:
fun = funcptr!bar;
:
```
Which works but neither dmd nor gdc were able to optimize the
additional function call away.
pragma(inline, true)
auto funcpt
On Friday, 14 October 2022 at 18:34:58 UTC, kdevel wrote:
dmd and gdc optimize the lambda invocations away. Nonetheless
the expression looks somewhat too big. To overcome this I tried
to generate the function pointer outside of the struct:
```
auto funcptr (alias method) ()
{
return &method
Given a struct `S` with method `foo`: Any of these expressions
```
&foo
&S.foo
&.S.foo
```
when they occur inside the struct they represent a delegate and
not a function pointer. Is it okay to "extract" and use the
function pointer from the delegate in this way:
```
struct S {
void