Etienne Kneuss a écrit :
Hello,

On Mon, Nov 16, 2009 at 2:51 PM, Mathieu Suen <mathieu.s...@easyflirt.com>wrote:

Etienne Kneuss a écrit :

 Hello,
On Mon, Nov 16, 2009 at 2:10 PM, Mathieu Suen <mathieu.s...@easyflirt.com
 *SKIP*
Static scoping is closely related to variable declaration. In PHP, there
is
no such thing as a variable declaration statement (apart from function
arguments or class members, which are correcly scoped).

I am pretty sure you can have static scoping without declaration statement.
Or you can consider "$a = 2" as a declaration statement.
Which imply that


if (..) { $a = 2; } else { $a = 3; }

Produce 2 bindings of $a or can be a free if you 'declare' it outside .
 As:

$a = null;

if (..) { $a = 2; } else { $a = 3; }


You simply cannot take $a = ..; as a variable declaration, otherwise $a = 2;
if (..) { $a = 3; } echo $a; would output 2, which is wrong.

Yes true, you need to distinguish declaration and assignment.
Mixing them in the same syntax is not a good idea.
But you could still do :

$a = 2;
if (..) { &$a = 3; }

But I don't really like it either.


In fact, you haven't really solved any of the two problems I described.


What's strange is that part of the language is statically scoped will the
other part is dynamic.
See function vs. if, loop statement.

Even worst if you think of the $_GET variable which should have a special
scope...


It's not strange, PHP does not have specific scopes for control structures,
and $_GET/$_POST can be considered as global variables. Of course it may not
be like language X or Y, but it makes sense considering the paradigm behind
variables in PHP.


I don't know if that's the right paradigm. What about continuation passing style? :)

-- Mathieu Suen

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to