Hi Marcus,
Hi Troels,

> The biggest issue I see is finding a syntax everyone likes.
Well, lets try some variations.

> Since renaming happens in a php array like
> style I would prefer to have that approach apply for ignoring methods as
> well. The way to do that imo is 'method=>false' or 'method=>NULL' which both
> should be obvious to PHP programmers that heard about Traits.
At first I'll have to make this clear. Aliasing != renaming.
It is not renaming operation. Aliasing will give you an additional
name for a method body.

By example:

trait Foo {
  public function foo() {echo 'foo';}
}

class FooFoo {
  use Foo {
    bar => foo
  }
}

This will eventually result in the following class at runtime:

class FooFoo { /* RUNTIME */
  public function foo() { echo 'foo';}
  public function bar() { echo 'foo';}
}

My idea behind this notation was the key => value thing

use Trait {
    additionalMethodName => method
}

but may be we should use a keyword here which will be more clear.

Troels ask for a separation of aliases and exclusions.
Here are some notation proposals:

[1] Explicit Except/Without List
use Trait except foo1, foo2 {
  bar => foo1
}

the keyword except could may be replaced by exceptfor or without if it
fits better.

[2a] ! is not readable --> except
use Trait {
  except foo1, foo2;
  bar => foo1
}

[2b] ! is not readable --> without
use Trait {
  without foo1;
  without foo2;
  bar => foo1;
}

[Aa] Aliasing is not obvious
use Trait {
  bar is foo1;  //aliasMethod is method
}

[Ab] Aliasing is not obvious
use Trait {
  bar from foo1;  //aliasMethod from method
}

I'm not sure about Aa and Ab because they do not read well in my opinion.

What do you think?

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

Reply via email to