On Mon, Nov 07, 2005 at 09:37:04AM -0800, Larry Wall wrote: : It would be nice to generalize this sufficiently to be able to declare : polymorphic objects resembling match objects: : : my $matchobj(Poly: Key^Int^Notthere --> Any); : : Or maybe that should be: : : my $matchobj\(Highlander); : : :-)
But seriously, I do keep wanting poly objects to keep trees in. For example, I want to represent XML with the tag attributes in a hash but the contents in a list: $obj = q:xml; # (conjectural here-xml syntax) <t1 a1="x" a2="y" a3="z"> text2 <t2/> text2 </t1> say ~$obj; # t1 say $obj.xml; # <t1 ... /t1> say $obj{a2}; # y say $obj[2]; # text2 say ~$obj.first('t2') # t2 say $obj.first('t2').xml # <t2/> Larry