Date: 07/05/00
- Next message: waldschrott: "Re: [PHP-DEV] RE:Class::? - accessing data, no success..."
- Previous message: Kristian Köhntopp: "Re: [PHP-DEV] What is 'var'"
- In reply to: waldschrott: "[PHP-DEV] adding objects with + equal to array process"
- Next in thread: waldschrott: "Re: [PHP-DEV] adding objects with + equal to array process"
- Reply: waldschrott: "Re: [PHP-DEV] adding objects with + equal to array process"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
waldschrott wrote:
> I think that would be useful with objects too.
> $obj->property='a'; $obj2->property2='b'; $resobj=$obj+$obj2;
> $resobj should then contain these properties
> $obj->property=='a' && $obj->property2=='b';
If you are treating objects like arrays, you probably
should have used arrays in the first place.
Usually, an object is a C struct with a predefined set of
slots, plus a set of functions operating on that struct.
In PHP, objects are different in the way that their set of
slots is not predefined, which makes them more hashlike than
structlike. This is nice, but it does not always help to
clear up the situation:
If you are using objects as hashes, you should have been using
arrays/hashes in the first place. That would enable you to
use all PHP array functions on them, which you cannot do
with objects.
if you are using object as objects, that is, as a predefined
structure associated with a set of functions manipulating that
structure, you should have defined your class as
class A {
var $someary = array(); // my array
function manipulate_array() {
...
}
}
$a = new A;
$a2 = new A;
and then use $a->someary[index] instead of $a->index. That
would enable you to use all PHP array functions on
$a->somary and $a2->someary without problems.
It is not necessary to change to language at all, except
perhaps for a php.ini switch will issue warnings if you
add slots to an object at runtime (you treat objects like
hashes) and wbhich should be enabled by default.
Also, what is the semantic of
$a = new A;
$b = new B;
$c = $a + $b;
What is the type and class of $c? What instance functions
are available to $c?
Kristian
-- Kristian Köhntopp, NetUSE AG Siemenswall, D-24107 Kiel Tel: +49 431 386 436 00, Fax: +49 431 386 435 99 Using PHP3? See our web development library at http://phplib.netuse.de/-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: waldschrott: "Re: [PHP-DEV] RE:Class::? - accessing data, no success..."
- Previous message: Kristian Köhntopp: "Re: [PHP-DEV] What is 'var'"
- In reply to: waldschrott: "[PHP-DEV] adding objects with + equal to array process"
- Next in thread: waldschrott: "Re: [PHP-DEV] adding objects with + equal to array process"
- Reply: waldschrott: "Re: [PHP-DEV] adding objects with + equal to array process"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

