CBFalconer wrote:
Peter N Lewis wrote:
A lovely feature I added to my own language when I wrote one about a dozen years ago was the construct "not in", eg:
if Ch not in ['A'..'Z'] then ...
I always thought this was much nicer than the ugly:
if not (Ch in ['A'..'Z']) then
as well as much clearer.
I don't know if others agree, but if so it might be a nice extension for GPC.
Anyway, just thought I'd mention it since I happened to be working on the docs for "in" ;-)
It may be pretty to you, but think about the penalties. Even if the parsing could be contorted to fit, any code written with it is immediately incompatible with everything else. Pascal is a portable language. The original syntax was carefully designed for one char and one symbol lookahead. How do you then handle:
if not ch = 'A'; (* illegal *) or if not boolvar <> true; (* legal *)
Well, that's not quite the same. In the latter case, you'd just omit a pair of parentheses, while Peter suggested to put the `not' beside the `in'.
Indeed, this doesn't seem to cause a parsing conflict (I suppose that's because both `not' and `in' are ISO 7185 keywords, therefore unique in their contexts). It's comparable to GPC's `and then' and `or else' (where EP adds new keywords `and_then' and `or_else', unnecessarily IMHO). So it seems to be easy to implement.
But I agree with the problems concerning portability, and we should consider if it's worth the trouble. I've run into such cases a few times in my own code and thought about such a thing, but not so often that I felt I really needed it. Of course, YMMV if you use sets very much ...
So I guess I'm neutral here ...
Frank