Kaz Kylheku
2023-07-30 21:39:53 UTC
https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/c11-generic/
In spite of _Generic being a compile-time type switch, the unused
clauses all have to type check with a given argument.
E.g. any of the cases maps an argument x to (x)->memb, then
the argument cannot be a "char *".
_Generic should only require that the clauses parse, using
the minimal amount of type information to that aim,.
(If the clauses don't parse, they cannot be identified,
so the construct cannot work. When sscanning the association
list, when the implementation encounters a nonmatching type,
it has to parse the associatead expression in order to find
the next clause in the association list.)
I would havce designed this with required parentheses:
_Generic(expr, t1: (e1), t2: (e2), ... :default (edfl));
Only the matching expression would be fully parsed; the non-matching
ones would be regarded as token sequences in which parentheses and
braces have to balance.
In spite of _Generic being a compile-time type switch, the unused
clauses all have to type check with a given argument.
E.g. any of the cases maps an argument x to (x)->memb, then
the argument cannot be a "char *".
_Generic should only require that the clauses parse, using
the minimal amount of type information to that aim,.
(If the clauses don't parse, they cannot be identified,
so the construct cannot work. When sscanning the association
list, when the implementation encounters a nonmatching type,
it has to parse the associatead expression in order to find
the next clause in the association list.)
I would havce designed this with required parentheses:
_Generic(expr, t1: (e1), t2: (e2), ... :default (edfl));
Only the matching expression would be fully parsed; the non-matching
ones would be regarded as token sequences in which parentheses and
braces have to balance.
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @***@mstdn.ca
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @***@mstdn.ca