Hi,

I'm not fully convinced we really need it, I had some moments in the
past where I wished they existed, but always found good solutions.

That said:

On Sun, 2010-04-04 at 18:28 -0400, Gregory wrote:
> The question I have is if we are not copying the array semantics 
> anymore, whether we should have abc('a' => 3) or abc(a => 3). I 
> personally would prefer 'a' => 3 because that allows for variable 
> parameter names.

Allowing variable parameter names means allowing any expression (else it
gets messy with inconsistent rules) which means that we allow a very
flexible syntax which might lead to code that's hard to understand. If
you don't know which parameters you want to provide maybe an array is
the better option. With such a syntax I expect more abuse than useful
use of the feature.

For do_something(parameter => 23); we have the benefit, that IDEs could
easily validate that which prevents typos and provide aid. But then I'm
not sure this fits to the language either as we always expect quoted
names. And from the some distance this looks like a constant used used
as parameter name, as in

  <?php
  const foo = 42;
  $a = array(foo => 'bar');
  do_something(foo => 'bar');
  ?>

Another possible limitation there is that our parser won't allow
keywords there. An example where this might be annoying might be
something along these lines:

  <?php
  function getInstance($param1 = 1, $param2 = 2, $class = 'default_class' {
      $r = new ReflectionClass($class);
      return $r->createInstance($param1, $param2);
  }
  getInstance(class => 'my_class');
  ?>

Just some random thoughts, maybe somebody has a better syntax, maybe
that's just me,
johannes


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

Reply via email to