Re: Config object and variable scopes
| From: | Hans-Peter Oeri | Date: | Tue, 09 Oct 2001 18:48:40 +0000 |
| Subject: | Re: Config object and variable scopes | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1653@lists.php.net to get a copy of this message | ||
On Tue, 9 Oct 2001, Andrei Zmievski wrote:
> When I'm writing template files, it is incredibly helpful to have this
> distinction -- I don't have to try and figure out that articleCharAbst
> is coming from config file versus from the application.
Yup, that's what I mean: It IS handy to distinguish, but I want to be able
to break it. That's why I only use one array of session variables in PHP -
but PHP does not IMPOSE it! That's the subtle difference.
Why is it wrong to impose something? I just don't like it... *grin*. I
LOVE C++ and I LOVE PHP because they allow me to write really clean and
good organized code while NOT imposing too much. If I want to get dirty, I
can do so. If I want to break MY (not someone else's) rules for debugging,
I can do so.
> > Other suggestion: If the imposed distinction is sacred... what about an
> > option to include to define the scope?
> Sorry, could not parse this last sentence.
Forget my sentence, I thought about it and suggest the following:
old behaviour:
Let's have different variable "name spaces": Application, Config, Runtime
By the variable prefix ($,#,%) we select the appropriate name space (we
can have the postfix optional, can we? please...)
new behaviour, variant a:
we introduce a new prefix that enables my "fallback": First look in
namespace "Application", then in "Config".
new behaviour, variant b:
we generalize the name space concept -> the programmer may define prefixes
for namespaces (the "old" spaces being defined as standard)
while assigning variables or including config files, there is an option to
define the appropriate name space for this action (the old behaviour being
the default):
{assign var="alpha" value="beta" } -> $alpha
{assign var="alpha" value="beta" space="CONFIG"} -> #alpha
{assign var="alpha" value="beta" space="APPLICATION"} -> $alpha
$smarty->assign( "alpha", "beta" ) -> $alpha
$smarty->assign( "alpha", "beta", "CONFIG" ) ->
#alpha
$smarty->assign( "alpha", "beta", "APPLICATION" ) ->
$alpha
{include file="alphafile"} -> #alpha
{include file="alphafile" space="CONFIG"} -> #alpha
{include file="alphafile" space="APPLICATION"} -> $alpha
We could then collapse the THREE functions to handle the different
variable types into ONE with an appropriate parameter (in the compiler
class) which would allow to streamline the code w/o loosing backwards
compatibility.
Did I describe it clear enough? I think this would be great ;)
Don't conform!
IkKampfCaspar75
PS: "Don't conform" is a motto assigned to me by my army mates and
describes exactly what I wrote above: I attain the goals, but in my own
ways.