In <[EMAIL PROTECTED]> A. Pagaltzis wrote:
 > * Paul Hoffman 
<[EMAIL PROTECTED]> [2003-09-19 15:06]: >> I'd like to get people's thoughts 
on this proposed module, >  > It's neat to have, although I suspect it won't 
be terribly useful.
 It's really just syntactic sugar.
 >> especially its 
name (Class::* doesn't seem right; Hash::Methods >> wouldn't be bad).  >  > 
I'm thinking Class::Struct::FromHash, myself.
 And I'm starting to think 
Class::HashLike.  Or maybe Class::Hash::Lite, since for the most part (i.e., 
not counting the autoblessing) it has a subset of Class::Hash's capabilities.  
Hmm, maybe the author of Class::Hash would be interested in adding an 
autoblessing option to Class::Hash. 
 >> Any hash ref retrieved for a Hash::
ObjectLike instance is >> automatically blessed into Hash::ObjectLike (
unless it's >> already blessed as something else). >  > Neato. Ideally the 
methods will be lvalue-subs, too, so you can > say something like >  >   $h-
>foo = 2;
 Yes, but I'd rather not restrict its use to versions of Perl with 
l-value subs.  I'm running Perl 5.6.0 on a couple of Macs.
 > It should of 
course also take >  >   $h->foo(2); >  > for the same effect.
 Yes, it does 
that.
 >> No distinction is made between non-existent elements and those >> 
are present but undefined. >  > I don't like this. It is easily possible to 
tell the object > whether it should croak on access to non-existent keys.
 I.
e., locking the object; something like this, I imagine:

  $obj = Hash::
ObjectLike->new(foo => 123, bar => 456);
  $obj->_lock;
 But how do you 
distinguish this from an attempt to access an element named '_lock'?  I 
don't want to exclude any element names, not even 'new', 'import', 'DESTROY' 
or 'AUTOLOAD'.  And not even 'can' and 'isa', if I can figure out how to do 
that.
 Or you can do it in the constructor, but that limits things too much 
for my likes.
 >> Furthermore, there's no way to delete an element without
>> resorting to C<< delete $h->{foo} >>. >  > Neither do I like this 
limitation, but I can't think of a > consistent way to add such to the 
interface.
 Well, I could make it so the user can do something like this:

  
use Hash::ObjectLike deleter => 'mydelete';
  ...
  $h->mydelete('foo');
 or 
maybe

  mydelete($h, 'foo');
 Similarly for exists.  But if someone wants 
that they should just use Class::Hash.

Thanks for your input.

Paul.

Reply via email to