Re: Empty Alternatives (a.k.a epsilon).

On Fri, Aug 28, 2026, at 14:50, Bethan Tovey-Walsh wrote:
> So how can you visually tell the difference between "cat" and "cat"? (That second one also has a zero-width space - U+200B - inside the string).
> 
> 
> 
> It sounds to me as though the real problem you're imagining here is people using unusual, non-visible, Unicode characters inside strings, rather than doing the sensible thing and using the hex codes so that the characters are explicitly readable. Anyone doing that is, I hesitantly propose, a bit of an idiot.  But "" is not more or less likely to contain a zero-width space than any other string.
> 

That has not been the case in my experience.

And, for whatever reason, people DO use unusual, non-visible Unicode characters inside strings. (Often because they want to influence hyphenation mechanisms or where the line breaks do or don't go in longer titles. Less often but memorably because they were using a these-chars-are-specific-tabs table formatting mechanism from ancient times. I'm sure I don't know all the reasons someone might do this.) And yes when you want the grammar to recognize these characters it is much better to write out the hex codes but that's also true of other mechanisms and I would not want to claim that people uniformly do so there.

> And if you write "cat"with fullwidth spaces (U+FF02), you'll get an error trying to read the grammar, since they're not valid string delimiters. Anyone doing that is a total idiot, and I feel zero hesitation in saying so.
> 
They might be using an environment (or an editor) where U+FF02 is the default quote mark.

Probably not, or at least probably not yet, but the possibility exists. People make mistakes. It's better if the mistake results in an immediate intelligible complaint from the mechanism rather than unexpected subtle differences of outcomes, so this case where the grammar gives an error is to my mind much better than a case where the grammar does (by user expectation) a weird thing.

-- Graydon

Received on Friday, 28 August 2026 19:25:57 UTC