Re: [SMARTY-DEV] Re: object support (more thoughts)
| From: | M Mohr | Date: | Tue, 14 Jan 2003 07:55:50 +0000 |
| Subject: | Re: [SMARTY-DEV] Re: object support (more thoughts) | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-534@lists.php.net to get a copy of this message | ||
On Mon, Jan 13, 2003 at 05:14:21PM -0600, Monte Ohrt wrote:
> If we force registration of objects, then you have to access an object like this:
>
> {$foo->bar}
> {foo->bar}
>
> This means you cannot have an array of objects to access in a section loop, such as:
>
> {section name=bar loop=$foo}
> {$foo[bar]->blah}
> {/section}
>
> If we need to support that, then it would mean objects must be assigned instead of registered.
> If they are assigned, then individual control over method access isn't really feasible,
> we would have to allow access to all methods exluding private ones. All or none. This also
> complicates the syntax, we are almost back to square one {$foo->bar()}
>
> So decisions:
>
> 1) register all objects, and can only access directly:
>
> {$foo->bar} <-- property
> {foo->bar p1="foo"} <-- method
>
> PROS: * syntax kept to a bare minimum
> CONS: * not as flexible can't assign arrays of objects
>
>
> 2) assign all objects, and allow access to all methods excluding private ones:
>
> {$foo->bar}
> {$foo.bar->blah}
> {$foo[bar].foo->blah}
> {foo.bar[foo]->foo p1="foo" p2="bar"}
>
> PROS: * can assign objects or arrays of objects, more flexible
> CONS: * syntax is more complex
> * can't control individual method access
what about registering (or allowing) methods for specific classes,
instead of objects? i think this will be flexible enough and may also
work with arrays of arrays of objects etc.
> I'm really leaning toward option #1. Is there a practical use for assigning
> arrays of objects?
>
> Monte
i lead more to #2, although #1 looks simpler and cleaner.
just a thought
messju