Markus Fischer wrote: > Hi, > > I started a scratch project with this patch and working with it seems > intuitive so far. > > My only question at the moment is the following, however I guess it > isn't specific to your NS patch then to Dmitry's: > > My current practice to declare an interface and provide concrete > implementation was like this: > > file: Foo/Bar/Interface.php > interface: Foo_Bar_Interface > > Now this gets problematic: > > file: Foo/Bar/Interface.php > namespace: Foo::Bar; > interface: Interface > > The last one doesn't work, because the source actually looks like: > > interface Interface { > > which gives > > syntax error, unexpected T_INTERFACE, expecting T_STRING > > I tried something like > > namespace Foo; > interface Bar::Interface; > > but that gives another parser error about the :: > > syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '{' > > Is there any chance for Rescue for this, instead of changing the naming > scheme?
Hi Markus, It is technically possible to fix this, on first glance it would involve having the lexer return a T_STRING for any non-whitespace following T_INTERFACE or between T_IMPLEMENTS and '{'. It would also need to return T_STRING following T_INSTANCEOF. However, this fix would only apply to interface naming, and would allow bizarre stuff like "interface class" or even "interface foreach" which is fine by me, but could be confusing to others (or so I've been told). Implementation would only touch the zend_language_scanner.l file, but would make it more complex. I've already gone down this road a few times, and you would also end up with inconsistent naming, as the solution could not work for classes because of the need to do ClassName::*. Implementing "ClassName::*" requires a lookahead token returning any whitespace and "::" back, which would slow things down a bit and complicate the lexer considerably, but it can be done. I'd be happy to do it but only if I have some reasonable assurance it would be accepted, it's a fair amount of work to patch the lexer and make sure it doesn't break crap. Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php