On 6/27/05, Michael G Schwern <[EMAIL PROTECTED]> wrote: > On Mon, Jun 27, 2005 at 01:41:30AM +0100, Fergal Daly wrote: > > I'm not sure there is a right way to deparse closures (in general). > > For example if a variable is shared between 2 closures then it only > > makes sense to deparse both of them together. Deparsing them in turn > > will lose the sharedness info. > > It would be less wrong than what B::Deparse is currently doing: completely > ignoring closure data. > > > > How many people would actually understand that caveat? > > About the same amount that use and understand closures.
Those that use are a subset of those that understand. > I'm perfectly happy to punt this problem over to B::Deparse and let them > figure it out. As it stands B::Deparse is the best we can do with code > refs. What's the alternative? I'd argue that currently the best you can do is == because it never gives a false positive. Consistent false negatives are harmless. > > > > For 2 B::Deparse works and might be the only way but then again, it > > > > might be better to just get access to the original string of code > > > > before it gets compiled, > > > > > > If they want to compare the original string they should have put it in > > > their > > > data structure. Simp. > > > > That is exacltly what I was suggesting, > > So are we just having an agreement? I'm not sure. My suggestion is rather than facilitating it behind the scenes, make it explicit and force it done by hand. It's actually the sort of thing that can be done as an extension to Test::Deep. So you could do cmp_deeply( [$subref1], [deparse_eq($subref2)] ); I might throw that in tonight, it's almost a one-liner. If someone really wanted, they could use XS to create subref_eq which pokes around inside closures, comparing the code and also comparing the value of closed variables but that seems extreme, F