Re: Named Parameters

From: Date: Fri, 09 Apr 2010 21:01:25 +0000
Subject: Re: Named Parameters
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-47849@lists.php.net to get a copy of this message
On 07.04.2010, at 16:16, Christian Schneider wrote:

my gut feeling also says that we shouldnt allow positional arguments after named parameters.
just picking out one of your examples .. 

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


couldnt this also be written as:

foreach (new T_User('firstname' => $firstname, "ORDERBY" =>
"age") as $user)

of course it would be a bit more work when constructing the final query, but its tons clearer in
terms of knowing how to use the API with just reading one use of the API and not the actual
implementation.

in the above code what is the purpose of the positional argument? can i just "append" what
I want? aka is the idea of the API to also support

foreach (new T_User('firstname' => $firstname, "LIMIT 100") as $user)

and

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

in that case it would still be better to then do:

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

.. of course its a few more characters, but its definitely easier to grasp whats going on, then
having to parse what is named and what is positional.

----

i am trying to remember what killed the discussion last time around. i think it was concerns over
having to convert all internal functions, but i guess that was before we unified the parameter
parsing API. IIRC hartmut was quite involved in the discussion back then .. maybe he remembers.

regards,
Lukas Kahwe Smith
mls@pooteeweet.org





Thread (19 messages)

« previous php.internals (#47849) next »