Hello out there.

Recently when I was working on a project, the idea came to my mind: allowing
the usage of undefined "dummy"-flags.

When I am speaking of "undefined dummy-constant", I mean if a variable is
being assigned the constant - and considering it's not defined -
the constant is being internally assigned an unique value.
It's complicated to explain. Maybe, a snippet of code makes you understand
my idea:

<?php
        // par exemple .. usage in a class:
        class XX {
                public $x = __XS;

                public function foo () {
                        return $this->x;
                }
        }
        $k = new XX;

        if ( $k->foo() == __XS ) {
                // -- this has been achieved without explicit definition of
XX->x!!
        }

        // or this way:

        $x = __FOO;
        $y = __NOOB;
        $z = __FOO;

        if ( $x == $y ) {
                print "This should then not be shown";
        } elseif ( $y == $z ) {
                print "This should then not be shown either";
        } elseif ( $x == $z ) {
                print "This would then be finally shown";
        }

?>

The idea behind the implementation - if possible - would then be, in order
to make this and constants work together, it could be checked this way:

If an undefined value is BEING ASSIGNED to a variable or returned by a
function, PHP defines it and assigns an unique - internal - value.
If an undefined value is NOT BEING ASSIGNED and NOT YET DEFINED and, for
instance, used in another context - like usage in a function or if-clause,
PHP falls back to the "Use of undefined constant".

I do not want to allow something like: __X = 2 (__X === 2), but something
like $x = FF; $y = DD; ($x === $y), I think of the dummy-constants not
really being something with a value, but rather something for
"identification" of values.

----
This might be considered as a request for comments.
----

Thanks for reading,
--
*Kenan Sulayman*
*Freelance Designer and Programmer*

Reply via email to