PHP 4.0 Bug #5377 Updated: Using :: on instance functions / future devolpment of PHP
| From: | Bug Database | Date: | Thu, 06 Jul 2000 14:43:44 +0000 |
| Subject: | PHP 4.0 Bug #5377 Updated: Using :: on instance functions / future devolpment of PHP | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-23594@lists.php.net to get a copy of this message | ||
ID: 5377
User Update by: waldschrott@kiffen.de
Status: Open
Bug Type: Feature/Change Request
Description: Using :: on instance functions / future devolpment of PHP
// another mail...
That is another weakness in the language, which leads to
abominations such as stdClass. PHP reports the TYPE of
"$o = new C;" as "object", but does not report the CLASS
of $o. That means that classes are not types and when you
set the type of a variable to object, it has no class at
all.
What is an object? Think of it as I have outlined in a
previous post, as a hash containing all instance variables
plus a hidden variable "isa" pointing to the class of
that object. You can serialize() that easily to
(classname, name/type/value of all instance variables).
What is a class? Think of it as I have outlined, as
a hash containing all instance methods, plus all
class variables, plus all class methods plus hidden
instance variable "isa" pointing to Metaclass. At the
moment you cannot properly serialize() that. One
way to serialize that is to generate autoloader
code for the include file defining that class, but
that assumes a 1:1 relationship between classes and
files.
It would be much more elegant to serialize() a class
as the values of all class variables, plus the compiled
bytecode of all instance and class functions. That way
you break the 1:1 relationship between classes and
include files, you get an easy way to manipulate precompiled
bytecode, and you solve the undefined class problem
when using session variables, as the code of serialized
objects becomes part of the session (and then you
store session objects in shared memory, and the magic
really happens, but that is for another discussion).
Full Bug description available at: http://bugs.php.net/?id=5377