I'm working on is_deeply() for Test::More in PIR. Handling nested data
structures is painful in PIR. I'm not asking for better abstractions to
handle that, just ideas on how to handle the algorithm.
Multidispatch helps, but :multi( Array, Array ) or :multi( Hash, Hash ) don't
work based on the capabilities of the PMC. That's fine.
With Parrot's type system, where the writer of the code (me) doesn't know at
code writing time what the type of the incoming data structures or individual
data members might be, what's a concise and maintainable way to port
is_deeply() to PIR?
(I keep asking myself "How would I do this in C?" and the answer keeps being
"Ugh, I wouldn't.")
-- c
Try a :multi first; if unsuccessful, compare type, and if match,
serialize both sides using freeze_pmc (or some kind of Dumper), and
compare the strings?
Thanks,
Audrey
> Try a :multi first; if unsuccessful, compare type, and if match,
> serialize both sides using freeze_pmc (or some kind of Dumper), and
> compare the strings?
I do have multis for primitive types (I,N,S,P), but when I have an array of
arrays to compare with an array of hashes or an array of ints things get more
complex, especially when I want to emit diagnostics about where the two data
structures did not match on failure.
I should have been more specific.
-- c
> Multidispatch helps, but :multi( Array, Array ) or :multi( Hash, Hash
> ) don't
> work based on the capabilities of the PMC. That's fine.
does_foo = does $Px, 'array' # 'hash'
might help.
There should be no problem with .Hash, but there are a lot of array
types around.
leo