If you want to write a new parser, or even just submit a patch to "fix" this, you'll probably figure out why you can't use "list" as a method name in your class... Or you'll actually submit a useful patch. :-) Either way, the problem will be solved, eh? :-) :-) :-) On Wed, December 6, 2006 12:22 am, Urbanose wrote: > > Yes, list() is a reservred word, but not instance->list(), nor > className::list(), nor $string = 'This is a list()';, etc. It makes > no sense. > > > Le 5 déc. 06 à 19:24, Richard Lynch a écrit : > >> >> >> list is a reserved word. >> >> Don't do that. >> >> On Mon, December 4, 2006 8:22 am, Urbanose wrote: >>> Hello there :] >>> >>> I wanted to build a method called "list". The problem is that once >>> I >>> do that, I get a >>> "PHP Parse error: syntax error, unexpected T_LIST, expecting >>> T_STRING" >>> error, because it's a "language construct". >>> >>> Here's the code that leads me to this error : >>> >>> <?php >>> class Foo { >>> function __construct () { >>> >>> } >>> function list () { >>> echo "Hello"; >>> } >>> } >>> $bar = new Foo (); >>> $bar->list(); >>> ?> >>> >>> So I made it working with a "__call" magic method, like this : >>> >>> <?php >>> class Foo { >>> function __construct () { >>> >>> } >>> function __call ($name, $arguments) { >>> echo "Hello"; >>> } >>> } >>> $bar = new Foo (); >>> $bar->list(); >>> ?> >>> >>> And it works. So there's my question : why can't we make methods >>> with >>> the same name as those used by "language constructs" ? I don't see >>> the point. Even less if you can make it work with the __call magic >>> method. >>> >>> Does someone have an explanation ? Is there a way to make this >>> possible for future versions of PHP, so that the classes namespace >>> is >>> really independent ? >>> >>> Don't tell me to use another name. Writting code like : >>> $books->list('all'); >>> or : >>> class Books extends Controller { >>> function list () { >>> # Instructions to list all books >>> } >>> } >>> makes things so much easier to read and self explanatory than >>> putting, for example, a "_" in front of it (_list). >>> >>> Thanks :] >>> >>> Urbanose >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> >> >> -- >> Some people have a "gift" link here. >> Know what I want? >> I want you to buy a CD from some starving artist. >> http://cdbaby.com/browse/from/lynch >> Yeah, I get a buck. So? >> > > Urbanose > > > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php