Variable Variable

Kay Schluehr kay.schluehr at gmx.net
Sun Mar 20 06:19:05 EST 2005


> I'm going to make this explicit:  the PHP idiom is a defect.
> Yes, I know that's good style among top PHP practitioners,
> but, from all I know, it's simply a bad habit.  The advice to
> use a dictionary is on target.

I tried to like it the whole last hour ;-)

I reconstructed the formal structure of $$var from a PHP Web-tutorial
though i do not have any experience with the language.

This is what i got:

        $               =
<Name> ---> <Var> --------------> <Var>x<String>
              |                        |
           $  |         #              |  $ o q' o proj2
              |                        |
              V                        V
            <Var> ----- f ------>    <Var>
              |                        |
              |         #              |  =
              |                        V
              +-----------------> <Var>x<String>
                        =

In the diagram $ is an operator that creates a var from a name, = is an
operator that binds a string to a var and q' drops quotations from a
string to get an name. The function f is an implied isomorphism. It
represents the equivalence of $$a and $b, where $a = "b".

Personally I could live with that, but the diagram is a bit special
because of the restriction of the = operation. I do not know if PHP
supports this operational view by enabling iterations: $a, $$a, $$$a
... ?

After all I can also live without that in Python...

Regards Kay




More information about the Python-list mailing list