|
|
|
|
|
by jrockway
6179 days ago
|
|
$self->data returns the value of the data attribute. The class is responsible for generating the identity of instances. The digest is only calculated when the object is stored. When it is retrieved and stored again (a no-op, since it's immutable), the ID is remembered and not recalculated. (Creating an identical new object will result in the digest being calculated again, of course.) The basic pattern for using this, once you've written the class: my $foo = Class->new( ... );
my $id = $db->store($foo); # 29837a387bffe...
my $foo2 = $db->lookup('29837a387bffe...');
Then this is true (the linker keeps note of the in-memory object IDs): refaddr $foo == refaddr $foo2
|
|
When you say the linker keeps note of the object IDs, does this mean the digests are stored outside of the objects themselves?