« Return to Thread: Implementing GtkTreeModel

Re: Implementing GtkTreeModel

by Elizabeth M Smith :: Rate this Message:

Reply to Author | View in Thread

Jake wrote:

> Matt,
>
> I'm not aware of a way to define a function named foreach since that's
> a reserved word in PHP.  However, I find the idea of reimplementing
> the GtkTreeModel functions (written in C) in PHP for speed extremely
> questionable.  If you could elaborate on when you observe a speed
> problem and how you intended to correct it PHP-side then I or others
> might be able to offer better advice.
>
> -Jake Cobb
>
> On Fri, Nov 7, 2008 at 4:35 PM, Matt <matt@...> wrote:
>> Ok, so I'm trying to create my own class implementing GtkTreeModel to
>> make it much faster when dealing with thousands of rows. The problem I
>> have is there is a method called "foreach" that makes PHP blow a gasket
>> when I try to define it.
>>
>> class TestTreeModel implements GtkTreeModel
>> {
>>        public function foreach($callback_func)
>>        {
>>                // do stuff
>>        }
>>
>>        // all the other abstract methods are defined properly
>> }
>>
>> This will return:
>>
>> Parse error: syntax error, unexpected T_FOREACH, expecting T_STRING in
>> foo.php on line xx
>>
>> Any idea on how to get around this? Thanks!
>>
>> -Matt
>>
>>
>> --
>> PHP-GTK General Mailing List (http://gtk.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

This is actually a bug in the php-gtk implementation and in the next
release (which should have cairo support as well) the functions that
conflict with php reserved words (foreach will be for_each, there are a
few others) will be renamed appropriately.  Until then, unfortunately
you're out of luck ;)

Thanks,
Elizabeth

--
PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

 « Return to Thread: Implementing GtkTreeModel