News for hackers. Stuff that matters.
Re:White space does matter in C23 by julesnp on Friday January 19, 2024 @01:37AM (#39052250)
I think the way F# implemented it is pretty good: if you want to use a keyword or whitespace in a variable or function name, it has to be enclosed in double backticks.

e.g:

  [<Property>]
  let ``Reverse of reverse of a list is the original list`` (xs:list<int>) =
      List.rev(List.rev xs) = xs
Re:White space does matter in C23 by lifthrasiir on Friday January 19, 2024 @03:15AM (#39052913)
I'm not sure if F#'s implementation is good enough. The specification [1] suggests that it doesn't do any additional normalization to the resulting identifier, so otherewise identical identifiers with a single space, a single tab and two spaces would be different. I would expect them to collapse into a single space character.

[1] https://fsharp.org/specs/language-spec/4.1/FSharpSpec-4.1-la...

Re:White space does matter in C23 by chrismorgan on Friday January 19, 2024 @05:07AM (#39053680)
Why would you expect that? I would explicitly expect not that. Unicode normalisation (typically to NFC) maybe, but nothing more.
Re:White space does matter in C23 by lifthrasiir on Friday January 19, 2024 @05:59AM (#39054040)
Mostly because it's rare to see identifiers with whitespace allowed after all. So this has to fulfill some specific needs.

The main use case here seems like self-describing properties that will be hardly referenced elsewhere. In principle this doesn't really need any new syntax, as you can put the description into the attribute (`[<Property>]` here) and the name itself can remain arbitrary or even be made anonymous. But we've got textual identifiers instead. So I guess that some code does refer to those textual identifiers, and if that's the case, being able to ignore invisible differences when comparing textual identifiers looks like a good idea as well.