Trait aliasing syntax suggestions

From: Date: Thu, 21 Feb 2008 06:55:56 +0000
Subject: Trait aliasing syntax suggestions
Groups: php.internals 
Request: Send a blank email to internals+get-35677@lists.php.net to get a copy of this message
Hi, Here is a slightly clearer syntax for trait instantiation and for aliasing/removing method names from traits: <?php trait foo { function bar(){} function bing(){} } trait bar { function bar(){} } class A { trait foo; } class B { trait foo {unset bing, bar as bing}; trait bar; } ?> Simply re-using "trait" instead of "use" is a more self-documenting solution. I found it slightly confusing to see "use" when that is a namespace-specific token currently. This is also in keeping with the way functions are defined in interfaces vs. implementation, but in reverse (for traits, brackets are used for declaration, semi-colon used for instantiation). Obviously, using "unset" is more similar to current PHP ideas on how to remove something, and the "as" syntax is also very PHP-ish, these will be far more self-documenting than the proposed syntaxes I've read thus far. Greg

« previous php.internals (#35677) next »