So far I only wrote up the RFC and kicked off a discussion here on the
mailing list about it. As I wrote several times already, I'd appreciate
someone tackling the implementation side to get a patch working!
Cheers,
Hi Ben,
I think there is something wrong with how I set up my ML subscription,
I had to go to the newgroup to get this as it didn't show up in my
inbox.
Anyway, ye, I'm having a crack at it, although slow since it my first
go at php-src.
I've run into a bit of a problem though.
I managed to get the syntax working for class declarations:
class_declaration_statement:
class_modifiers T_CLASS
{ $<num>$ = CG(zend_lineno); }
T_STRING
generics extends_from implements_list backup_doc_comment
'{' class_statement_list '}'
{ $$ = zend_ast_create_decl(ZEND_AST_CLASS, $1, $<num>3, $8,
zend_ast_get_str($4), $6, $7, $10, $5); }
| T_CLASS
{ $<num>$ = CG(zend_lineno); }
T_STRING
generics extends_from implements_list backup_doc_comment
'{' class_statement_list '}'
{ $$ = zend_ast_create_decl(ZEND_AST_CLASS, 0, $<num>2, $7,
zend_ast_get_str($3), $5, $6, $9, $4); }
;
class SampleMap<K, V>
{
}
So far so good, but function calls are more complicated. I'm getting
error: shift/reduce conflicts
My guess is this due to the following scenario:
<?php
define('const_a', 1);
define('const_b', 2);
$result = const_a < const_b > (10);
While the intention might be to call a "function" const_a with the
generic type const_b and 10 as an argument, it is also identical to a
comparison expression.
The example above throws: Parse error: syntax error, unexpected '>'
since the expression is erroneous , so should that allowa generic type
to be included to the syntax?
So far so good, but function calls are more complicated. I'm getting error: shift/reduce conflicts
My guess is this due to the following scenario:
<?php
define('const_a', 1);
define('const_b', 2);$result = const_a < const_b > (10);
While the intention might be to call a "function" const_a with the generic type const_b and 10 as an argument, it is also identical to a comparison expression.
The example above throws: Parse error: syntax error, unexpected '>' since the expression is erroneous , so should that allowa generic type to be included to the syntax?
Hm, this is indeed an "interesting" issue I didn't think about when
writing up the RFC. Sadly, I have no idea about how to solve this issue.
If you have no idea either on how to solve this, I'd suggest to skip
generic methods for now and concentrate on generic classes only.
--
Ben Scholzen 'DASPRiD'
Community Review Team Member | mail@dasprids.de
Zend Framework | http://www.dasprids.de