Hi Gerald,

I had an idea regarding the issue of having variables which are visible
to all pages in any request. Currently we get a Request object passed in
on the stack, which we can set variables in. However I have found this
to be rather inconvenient due to the extra syntax involved with
accessing such variables. For instance instead of $foo we now have
$req->{foo}. As a result I currently include files from base.html into
the same package. This enables me to have simple variables which are
shared between files.

However, there are potential problems with using the same package, and
it also short circuits the inheritance mechanisms. 

Here's the idea: We currently get certain variables made available to
each page, such as %fdat. What if there was an object similar to (but
not the same as) $req, where we could set variables; call it, say,
$global. Then, we have $global passed in on the stack (like $req). But
in addition, we also get all the variables which have been set in
$global set directly in the current package, automatically, like %fdat.

For example, in one page we say $global->{foo} = "hello"; then, in
another (subsequently executed) page we would have a variable called
$foo automatically initialized for us to "hello".

If you then change one of these variables, the change is reflected for
other pages. I don't know if this is technically possible because I am
still a little fuzzy on the details of how Perl manages namespaces and
variable references. But, knowing Perl, it should be possible...

Does this make any sense? It would enable more global variables and make
it easier to code these, while keeping each page in its own package, and
resulting in tidier code (in my opinion). I'm just thinking about the
variables that Embperl currently automatically sets for us - couldn't it
also automatically add references to other variables, based on the
contents of an object like $global?

This is just an idea, perhaps not fully formed, and I have no idea how
hard it would be in practice. Any comments?

TIA

-Neil

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to