is there a reason why pike allows whitespace between ( and [ for ([ ? (same for ]) and ({ }) of course)
i always viewed ([ as an inseperable entity (like += or other multicharacter elements)
can anyone explain this?
greetings, martin.
I think that's a side effect from keeping the parser simple. A lexer is always greedy, so whenever "([" is together in a file then it'd be parsed as a single token. However, there are cases where you can get the two tokens "(" and "[" next to each other. e.g:
string foo = ([string] bar) + "\n";
It'd be necessary to have a lot of extra special case rules in language.yacc to handle these without forcing users to put some space between "(" and "[".
ah, thank you, that makes sense.
so it is not intended but unavoidable...
greetings, martin.
Yes. There's another way it could be fixed, though: The parser could do an ad-hoc check for whitespace in those places when it reduces the closing ")" of a ([...]) or ({...}). But it's not really worth the bother.
well, occasionally someone gets creative and actually expects the whitespace there to work, and be in for a surprise if that ever changes...
if that is of any concern it better be changed earlier than later.
also i think it makes for really unreadable code. (but then there are plenty of other ways to make code unreadable...)
greetings, martin.
pike-devel@lists.lysator.liu.se