This is a quick sketch of an idea I was having today, written down and sent
into the ether before I get off the bus and forget:

I want a way to coerce any kind of object with the X nature out of a hashref by
having it call Class->new(hashref).  An inflater could handle this for simple
cases.  The problem is that I do not want to write:

  coerce 'Class::A' => from 'HashRef' => via { Class::A->new($_) };
  coerce 'Class::B' => from 'HashRef' => via { Class::B->new($_) };
  coerce 'Class::C' => from 'HashRef' => via { Class::C->new($_) };

If these are all isa Class::Base, I don't know how this could help.  I don't
think even the quietly-muttered-about type coersion cascading is likely to be
useful for this.

I just like the idea of saying:

  my $o = Object->new(
    foo => 1,
    bar => 2,
    obj => {
      quux => 3,
    },
  });

-- 
rjbs

Attachment: pgpxbEpQhHv1m.pgp
Description: PGP signature

Reply via email to