Re: objects: one more approach

From: Date: Wed, 15 Jan 2003 16:37:27 +0000
Subject: Re: objects: one more approach
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-540@lists.php.net to get a copy of this message
$foo->bar(array('p1' => "foo", 'p2' => $bar), $this); Deffinitly better. Lower parse time to accomplish this, and it's just much easier to do ;) Besides, why make things different all the time? If you use it for plugins and such, use it for objects :) -- Eric Coleman eric.coleman@sitemod.net sitemodCMS - http://sitemod.net "Monte Ohrt" <monte@ispi.net> wrote in message news:1042647345.2123.66.camel@lena.ispi.prv... > How about this. > > You assign objects just like variables. Let's say $foo is an assigned > object. > > At first I thought about this syntax: > > {$foo.bar} <-- property > {$foo.bar p1="foo" p2=$bar} <-- method > > But, this isn't simple because at compile time the parser doesn't know > if $foo.bar is an array or an object, they require different syntax in > the compiled template. I could either pass this to a function and figure > it out at runtime (extra step), or use a separate syntax for objects: > > {$foo->bar} <-- property > {$foo->bar p1="foo" p2=$bar} <-- method > > ok, now we know at runtime if it is an object, and how to compile it. > Also with this syntax of passing parameters it is nothing new for the > parser. The one problem I see is no distiction between a property and a > method with no args. Ideas? Maybe we don't worry about it. If the method > exists, use that. Otherwise use the property. > > If an object is not registered, you have access to all methods and > properties except private ones. If registered, then restricted access to > registered methods (but leave access to properties, or register them > too?) > > I'm also wondering how the object parameters should be handled. example: > > {$foo->bar p1="foo" p2=$bar} > > which should happen? > > $foo->bar("foo", $bar); > > or > > $foo->bar(array('p1' => "foo", 'p2' => $bar), $this); > > Notice the second one is much like registered functions, all parameters > are passed as an array in the first argument, and the smarty object > passed in the second. Maybe we should do this with objects too. > > Monte >

« previous php.smarty.dev (#540) next »