-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2 Apr 2007, at 22:47, Yuval Kogman wrote:
I explicitly don't want $wider and $mono to be /clones/ of $base - I want them to /be/ $base but with modified parameters. Semantically it behaves as if an instance handle ($base, $wider, $mono) binds
parameters to an object so instead of

Proto based OO usually does not imply cloning, but a linked list
lookup chain thingy, where props in the derived object shadow ones
in the ancestor, but modification to the ancestor will reflect in
all the children.

Yes, that's close - but I /think/ there's still a distinction. Let's suppose that instead of eliminating the mutability of the base object I'm trying to minimise it - that still has value. I think I'm right in saying that in general in prototype based systems assignments to properties target the object at the front of the prototype chain.

So if the object was completely immutable, normal prototyping would be semantically identical to what I'm describing. But if I still want to be able to set properties and have the underlying object update correctly I'd need to add some magic. Is that right?

With conventional prototyping if I do

$base    = Thing->new;
$derived = $base->variant_or_clone_or_whatever( { modify => 'something' } );

and then

$derived->set_some_field( 'Aark!' );

by default I'd be assigning to a field within $derived rather than within $base.

If you want this for testing Test::MockObject::Extends works well,
if you want it for real code I guess you could cannibalize that, but
I doubt you'll find this as a pattern anywhere else because most
languages that have a pattern naming culture lack the flexbility to
do these tricks

I think I know how to write it - I'm just curious to know if it has a name so I can do some more reading and describe it using the same terminology as the rest of the world :)

- --
Andy Armstrong, hexten.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)

iD8DBQFGEX7pwoknRJZQnCERAtzEAJ9aKlYL0XQIhDmEv8PkphhLHHOO5QCfQhXs
QbSAqthP6jCe88xbJNMLiEc=
=5VKx
-----END PGP SIGNATURE-----

Reply via email to