Req #63713 [Opn->Wfx]: Need an "UNDEFINED" type

From: Date: Fri, 07 Dec 2012 01:51:00 +0000
Subject: Req #63713 [Opn->Wfx]: Need an "UNDEFINED" type
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-175178@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63713&edit=1

 ID:                 63713
 Updated by:         aharvey@php.net
 Reported by:        liquid_nitrogen_4ever at yahoo dot com
 Summary:            Need an "UNDEFINED" type
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Variables related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

I don't see much value in this: it's an unusual use case, would require engine changes,
and you can already check if a variable is defined with
array_key_exists('notExistentVariable', get_defined_vars()).


Previous Comments:
------------------------------------------------------------------------
[2012-12-06 17:42:43] liquid_nitrogen_4ever at yahoo dot com

Description:
------------
Consider the following scenario currently in PHP:

var_dump($notExistentVariable);
-> NOTICE: Undefined variable notHere on line 1
   NULL

isset($notExistentVariable);
-> FALSE

$foo = null;
var_dump($foo);
-> NULL

isset($foo);
-> FALSE


If there were an UNDEFINED "type" (in the same sense that there is a NULL), the 
above scenarios would change to:

var_dump($notExistentVariable);
-> UNDEFINED

isset($notExistentVariable);
-> FALSE

$foo = null;
var_dump($foo);
-> NULL

isset($foo);
-> TRUE

However, unlike NULL, you would NOT be allowed to explicitly initialize 
something to UNDEFINED.
$x=UNDEFINED;//error:  if you want it to be undefined, don't declare it.

However, having just:
$x;

makes sense (to me at least) as shortcut to:
$x=NULL;

In other words, if a variable is declared but not explicitly initialized, it 
will implicitly be set to NULL (which is 
essentially what you are already doing, but one can't really differentiate 
between declared and undeclared variables).



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63713&edit=1


Thread (3 messages)

« previous php.bugs (#175178) next »