On Sunday, 21 September 2025 at 20:33:11 UTC, user1234 wrote:
On Saturday, 20 September 2025 at 02:36:47 UTC, Steven Schveighoffer wrote:
What is a function type? It's the internal type that the compiler has for a function, which you actually cannot express in syntax.

Actually D has a syntax to expression function types:

```d
alias FT = void(int);

void v(int a){}
static assert(is(typeof(v) == function));
static assert(is(typeof(v) == FT));
```

Well, I was sure you couldn't do this! I thought the only way was to use `typeof` on an actual function.

But I stand corrected.

Looking at historical compilers, the `alias ... =` syntax was added in 2.087.0. But before then, you could also do it like:

```d
alias void FT(int);
```

Which gives me so much C vibes...

-Steve

Reply via email to