Dan Sugalski wrote:
>
> At 04:39 PM 10/1/00 -0700, Peter Scott wrote:
> > What are the chances of the internals supporting user-defined
> >attributes? What would the API look like?
>
> Well, yeah, it'll sort of have to if we allow user-defined types. If you do:
>
> my Dog $spot : male;
>
> then the Dog package needs to be able to fetch the attributes. I've no idea
> how that'd look--perhaps an attributes() function, a method in UNIVERSAL,
> or something like that.
if attributes are stored as one hash per attribute, with somthing intransient
about the target objects used as the keys (like its reference stringification)
rather than being stored with the object, requiring larger objects, the entire
attribute syntax might be possible to convert into an access to those hashes.
The only sticky part I can see is what to call them.
%UNIVERSAL::ATTRIBUTES::your_attribute_name_here
perhaps?
This would make Dan's example expand to:
my Dog $spot; $UNIVERSAL::ATTRIBUTES::male{\$spot} = 1;
Magic would be required to delete an objects attribtes on destruction;
the requirement to store this magic might invalidate any gains from doing
it this way.
--
David Nicol 816.235.1187 [EMAIL PROTECTED]
"After jotting these points down, we felt better."