4 ms·
Just admit that it's pattern matching, and introduce a new variable for each match: ``` _Generic(expr0, type1 id1?: expr1, ... typeN idN?: e
by reichstein 3y ago
Just admit that it's pattern matching, and introduce a new variable for each match:
```
_Generic(expr0,
type1 id1?: expr1,
...
typeN idN?: exprN,
default id0?: exprDefault
)
```
Every identifier is optional, but if you include `idX`, it gets bound to the value of `expr0` with type `typeX` in the following expression, or with the type of `expr0` for the default case.
Then you can safely refer to the value at its now-known type, even if `expr0` was not a variable to begin with.