On 4/15/02 10:24 PM, Larry Wall wrote:
> So the main reason that objects can function as hashes is so that the
> user can poke an object into an interface expecting a hash and have it
> "make sense", to the extent that the object is willing to be viewed like
> that.

Sure, by why should that be the default?

> And the default operator:{} method will let the user access the
> existing accessors as if they were keys in a hash.  And maybe even use
> keys() on the object to get a list of available accessor method names.

I think I liked this idea better when it was called tied hashes, and when it
had to be explicitly enabled by the programmer, rather then explicitly
disabled.

> If you don't want your objects used this way, it'd be trivial to
> override the operator:{} method.

I'd turn that around and say: if you want your object to behave like a hash,
it'd be trivial to inherit from the HashAccessors class (or whatever).  It
just doesn't seem like something that should be in UNIVERSAL (or "on by
default", however that's implemented in Perl 6).

IMO, fancy tie-like object-as-another-data-type ("tagmemics"? ;) features
should need to be explicitly enabled by inheritance and/or operator
overloading (I see your point about the pragma technique).

-John

Reply via email to