Change History

After some thinking on this, I think the right way to do this would be to give the programmer the choice, i.e. put another field in the ParseMode? record for how to act on unrecognised pragmas.

Note though that there's a difference between unhandled pragmas (such as UnicodeSyntax?) and unrecognised pragmas. It would probably make sense to fail by default for unhandled pragmas, but accept by default for unrecognised ones.

If an unhandled or unrecognised pragma doesn't affect syntax, then there is an upside to accepting it, since the file can still be parsed fine.

However if it does affect syntax, then I can't see any such upside, since parsing is very likely to fail later with a more cryptic error, or produce a bad result.

So for unhandled pragmas known to affect syntax, failing by default makes perfect sense. If there are any unhandled pragmas known not to affect syntax, then accepting by default would be reasonable, but do any such things exist? As far as unrecognised pragmas go, obviously HSE can't know whether they do affect syntax or not, but my guess is that most pragmas do affect syntax and so I think the default should still be to reject.

Overall it seems to me like it would simplest just to default to rejecting anything unhandled or unrecognised, and have a flag to override this as suggested.