Re:White space does matter in C23
by nerdponx on Thursday January 18, 2024 @02:44PM
(#39046600)
Meanwhile both SQL (and more recently Python) have tokens that are keywords in certain contexts and regular identifiers in others.
[ Parent
| on HN ]
Re:White space does matter in C23
by Findecanor on Thursday January 18, 2024 @03:03PM
(#39046875)
PL/I was infamous for it being possible to express valid code that read "IF IF THEN THEN ELSE ELSE".
Re:White space does matter in C23
by colejohnson66 on Thursday January 18, 2024 @03:16PM
(#39047026)
Yep. One of the goals was that there would be no reserved words. Not sure why.
IF IF = THEN THEN THEN = ELSE ELSE = END ENDC++ has some contextual keywords as well:
final (C++11)
override (C++11)
import (C++20)
module (C++20)But did they make those contextual in order to avoid conflicts with code that had existing identifiers before the new keyword was specified?
Yes.
Re:White space does matter in C23
by tsimionescu on Friday January 19, 2024 @01:36AM
(#39052237)
C# is probably the king of contextual keywords, they have tens of them. They started I believe with `yield return` and `yield break` and then added all of the LINQ ones (select, from, where etc), and kept adding others (notnull, record, required, etc).
Java too:
> A further ten character sequences are restricted keywords: open, module, requires, transitive, exports, opens, to, uses, provides, and with. These character sequences are tokenized as keywords solely where they appear as terminals in the ModuleDeclaration, ModuleDirective, and RequiresModifier productions (§7.7).
https://docs.oracle.com/javase/specs/jls/se12/html/jls-3.htm...