> >> $foo = new Bar(); > >> $a = 'my_method'; > >> $result = $foo->{$a}(); > >> > >> Very useful sometimes. > > > > Yes, but indirection can easily be overused. Please don't overuse as it > > makes reading other's code that much harder. > > > > Hah, just imagining a project from hell that would define() all of the > method names in an include and then make calls like the following: > > $result = $foo->{ MY_METHOD_1 }(); > > ... because then if the foo interface ever changes, all you have to do > is update the include file. :-D
That's crazy talk. -- defining/reading constants is expensive - performance -- when an interface to an object changes, it's likely going to be more than just syntactic sugar and the names of the methods -- looks weird -- it's just strange -- indirection is never implemented in an organized way There, I said it :) H _______________________________________________ New York PHP User Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/show_participation.php