Non trailing whitespace means the string doesn't end with a space. But foo is a function that converts an AST to a string, that's totally different. Or it's a function that loops until \0 and changes all spaces to +

The spec should be a summary of what the impl is supposed to do. You'd want more than just doesn't end with whitespace of course.

> Non trailing whitespace means the string doesn't end with a space

No. And this is a great example of the problems with specifications. You still have to write a spec. And this, too, is subject to bugs.

What's wrong with the statement above is there are 17 space characters in Unicode and another eight whitespace characters, like newline.

If you try to verify that something ends in whitespace, you have to make sure you have the right definition.

Not picking on parent poster! It's just a great example of the fact that you can verify, but if what you are verifying is wrong, it doesn't help.

> there are 17 space characters in Unicode and another eight whitespace characters, like newline.

And of course, those 25 characters don't include ZERO WIDTH {SPACE,NON-JOINER,JOINER,NON-BREAKING SPACE} and WORD JOINER, which gives you yet another 5 arguably "it's kinda space, right" codepoints which definitely should not be trailing in any reasonable text string.

Unicode never ceases to amaze me.