Session "Of Lambda Functions, Closures an Traits"

30 October 2008 in Allgemein and IPC

Den Vortrag hatte ich schon auf der Froscon gehört.
Vorgetragen von Sebastian Bergmann dieser hat den Vortrag in zwei Teile geteilt. Da
seine Folien bald zur Verfügung stehen werde ich einfach nur paar Stichpunkte mit Codebeispielen hinterlassen.

PHP 5.3
Lambda Functions
- Anonymous
- kein cache

Beispiel:

$test = function() { print 'Hello World'; };
call_user_func($test);
call_user_func($test, array()); //Reflection API

Closures

$string 'Hello World';
$test = funcion () use ($string) { print $string;};
$test();
print $test;


PHP 5.4
Traits
- Lightweights
- Stateless
- Flexible composition of behavoir into class
- exists implementations: Perl 6,Squeuak, Scala, Self,Slate,Fortress
new keyword "trait"


trait T
{
public functiion a(){
}
}

class B extends A
{
use T;
}


Categories: Allgemein and IPC | Words: 169