Skip Menu |

This queue is for tickets about the Class-Std CPAN distribution.

Report information
The Basics
Id: 15032
Status: rejected
Priority: 0/
Queue: Class-Std

People
Owner: Nobody in particular
Requestors: paull [...] peak.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.0.4
Fixed in: (no value)



Subject: Using the anon_scalar for ID storage
It occurs to me that the anon_scalar could be used to store its ID. Instead of using $root_of{ident $self} we would write $root_of{$$self}. I'm sure I don't understand all the implications of this (threads etc) but it seems like trading a dereference for a function call should be a performance win, and I find it less cluttered visually.
Date: Fri, 14 Oct 2005 15:21:51 +0200
From: Damian Conway <damian [...] conway.org>
To: bug-Class-Std [...] rt.cpan.org
Subject: Re: [cpan #15032] Using the anon_scalar for ID storage
RT-Send-Cc:
Show quoted text
> It occurs to me that the anon_scalar could be used to store its ID. > Instead of using $root_of{ident $self} we would write > $root_of{$$self}. I'm sure I don't understand all the implications of > this (threads etc) but it seems like trading a dereference for a > function call should be a performance win, and I find it less > cluttered visually.
Sure, but it also means that you can duplicate an object just by duplicating its contents. Which also means you can spoof any object just be replacing the contents with a value that happens to be the ID of another. That's why I decided against caching the key in the object. Of course, nothing prevents you from doing this manually yourself. For example, you could set up a BUILD that includes: $$self = ident $self; and thereafter use $someattr_of{$$self} as you wish. Damian