Hi!

> I know I shouldn't write "Ruby" in the subject of a letter for  
> php-internals ML, but... Just wanted to ask, is anybody interested in this  
> feature in PHP?

As I understand, :foo is basically an interned string "foo". But in PHP
all constant strings are interned now, so the only thing we gain is
comparison speed. Given that the strings we're talking about is under 10
chars, performance gain from this would be negligible, and symbols
aren't frequently directly compared anyway. So what exactly we're
gaining that is not there in just constant string?

> $foo = array();
> $foo[:bar] = "qwerty";
> 
> var_dump($foo);
> // array(1) {
> //  [0] =>
> //  string(6) "qwerty"
> //}

Here's a problem. How we know that :bar is 0? What if we serialized $foo
and later loaded it back - would :bar still be 0? Would :bar be 0 in all
scripts forever - and if not, how would we know where $foo[:bar] is
actually stored when we combine two scripts? I think it can not work
this way since link between :bar and actual hash key should be stable.

> I will drop the part about new variable type, the main thing is how  
> HashTables could work with symbols as keys.

HashTable can accept only string or number as key. As we have seen
before, making number from :bar is very hard to pull off properly. And
if we use string "bar", why not just use string "bar"?

> 1. More convenient way to use it almost everywhere as a replacement for  
> strings and sometimes for constants. There's a lot of code that uses  
> arrays as a parameter-stores. For example, here's how you usually define a  
> form in Symfony2:

How it's more convenient? I don't see any difference.

> 2. Memory usage reduction. AFAIK, there's a lot of cases like the above  
> and the use of symbols would affect on memory usage significantly.

I don't see any memory usage reduction - you still have to store the
string. Could you explain how memory usage is reduced?

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to