Jeremy White wrote:
> Robert May wrote:
How about something like this:
- The 'userdata' member of the (internal) stored data always holds a hash. The UserData method stores the passed SV in the 'UserData' member of that hash. The 'Data' method stores the passed SV in the hash with a key equal to the current classname (obtained from ref($_[0])). As you can't have 2 classes with the same name in an inheritance hierarchy, nothing ever clobbers anything else.

This would be problematic if you ever wanted access to your instance data from a different package from where you set it - but you really should be using accessor methods to do this anyway.

Does this work, and is it sensible?

Very interesting and elegant solution. I can't see why this wouldn't work. Just so I understand you:

The userData SV on PERLWIN32GUI_USERDATA, will become a hash if it is ever used (perhaps we should rename this member?). When the user calls the UserData method to store data, the data is stored in the hash with the key 'UserData'. If the Data method is used to store data, the class name of the object will be used to store the data in the hash.

Exactly as I intended.  Yes to re-naming the userdata member.

Rob.

Reply via email to