Tjerk Anne Meesters wrote:
> In the case whereby names parameters are "plucked" from the argument
> list and passed as a hash to the function it really shouldn't matter
> whether that's invalid in python; both (2, 'name' => 'test') and
> ('name' => 'test', 2) would yield the same results, albeit it's a
> highly dubious way of passing arguments ;-)

Actually we use "positional" (scalar) both after and before "named"
(associative) parameters a lot for HTML generation and DB queries:

$html = table('class' => "beautiful",
        tr(
                td("foo"), td("bar"),
        ),
        tr(
                td("qux"), td("quux"),
        ),
);

foreach (new T_User('firstname' => $firstname, "ORDER BY age") as $user)
        ...

$bar = it::replace('Foo' => "Bar", $foo, 'casesensitive' => true);

So any solution restricting named parameters to any of
- declared named parameters only
- not allowing alternating named/positional parameter sets while
maintaining these sets and order
would not fit our needs.

As a result our patch (and syntax converter in both directions for
unpatched webservers) uses a simple but somewhat limited approach:
Any sequence of key => value pairs in a function call are surrounded by
array() (done at compile time). This means functions accepting
interleaved named/non-named parameters need to do some varargs parsing
and sometimes you need to still manually add array() if you want to
separate two sets of named parameters (but that's a questionable API in
most cases).

More info: http://cschneid.com/php/INFO_README
Patch and manual converter: http://cschneid.com/php/
Autoloader with automatic syntax conversion: http://itools.search.ch/

I know I've mentioned this here before but I still think its pros and
cons should be taken into consideration when talking about this subject,
- Chris

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

Reply via email to