Re: is_deeply() and code refs

2005-06-30 Thread demerphq
On 7/1/05, Michael G Schwern <[EMAIL PROTECTED]> wrote: > On Thu, Jun 30, 2005 at 09:44:06AM +0200, demerphq wrote: > > > Out of curiousity, if Data::Dumper::Streamer can handle > > > closures why not fix B::Deparse? > > > > I'm not really sure what you mean by "fix" B::Deparse. B::Deparse does > >

Re: is_deeply() and code refs

2005-06-30 Thread Michael G Schwern
On Thu, Jun 30, 2005 at 09:44:06AM +0200, demerphq wrote: > > Out of curiousity, if Data::Dumper::Streamer can handle > > closures why not fix B::Deparse? > > I'm not really sure what you mean by "fix" B::Deparse. B::Deparse does > exactly what it says it does: it deparses code. We can't consider

Re: is_deeply() and code refs

2005-06-30 Thread demerphq
On 6/30/05, demerphq <[EMAIL PROTECTED]> wrote: > Incidentally this is a pretty common mistake when handling REF's. > Data::Dumper does it as does YAML and pretty much all the other > storage tools that i have looked at, although Storable gets it right. > Also, i should say that while this circular

Re: is_deeply() and code refs

2005-06-30 Thread demerphq
On 6/30/05, Michael G Schwern <[EMAIL PROTECTED]> wrote: > On Thu, Jun 30, 2005 at 08:03:32AM +0200, demerphq wrote: > > Yitzchak pointed me to this thread. I thought I'd add that > > Data::Dump::Streamer v1.14 has the capability to Dump closures > > properly, that is including bound lexical state.

Re: is_deeply() and code refs

2005-06-29 Thread Michael G Schwern
On Thu, Jun 30, 2005 at 08:03:32AM +0200, demerphq wrote: > Yitzchak pointed me to this thread. I thought I'd add that > Data::Dump::Streamer v1.14 has the capability to Dump closures > properly, that is including bound lexical state. Interesting. is_deeply() can try to use Data::Dumper::Streamer

is_deeply() and code refs

2005-06-29 Thread demerphq
Hi, Yitzchak pointed me to this thread. I thought I'd add that Data::Dump::Streamer v1.14 has the capability to Dump closures properly, that is including bound lexical state. (Albeit with a few minor caveats, its possible to deliberately construct pathological closures that wont be eval'able, howe

Re: is_deeply() and code refs

2005-06-28 Thread Fergal Daly
On 6/28/05, Michael G Schwern <[EMAIL PROTECTED]> wrote: > On Mon, Jun 27, 2005 at 11:34:58PM +0100, Fergal Daly wrote: > > Forgetting philosphical arguments about what's the right thing to do, > > I think the strongest point against this is that there may be people > > out there who expect the cur

Re: is_deeply() and code refs

2005-06-28 Thread Fergal Daly
On 6/27/05, Michael G Schwern <[EMAIL PROTECTED]> wrote: > On Mon, Jun 27, 2005 at 11:20:07AM +0100, Fergal Daly wrote: > > > 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 th

Re: is_deeply() and code refs

2005-06-27 Thread Michael G Schwern
On Tue, Jun 28, 2005 at 12:21:48AM +0100, Fergal Daly wrote: > That's only 2 months old (according to CPAN) before that it would have > just failed or passed (failed in this case). Is it in bleadperl? I'd > be amazed if no one anywhere was using is_deeply with coderefs. It was undefined, accidenta

Re: is_deeply() and code refs

2005-06-27 Thread Michael G Schwern
On Mon, Jun 27, 2005 at 11:34:58PM +0100, Fergal Daly wrote: > Forgetting philosphical arguments about what's the right thing to do, > I think the strongest point against this is that there may be people > out there who expect the current behaviour The current behavior is to vomit all over the use

Re: is_deeply() and code refs

2005-06-27 Thread Michael G Schwern
On Mon, Jun 27, 2005 at 11:20:07AM +0100, Fergal Daly wrote: > > 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

Re: is_deeply() and code refs

2005-06-27 Thread Tels
-BEGIN PGP SIGNED MESSAGE- Moin, On Monday 27 June 2005 00:37, Michael G Schwern wrote: > On Sun, Jun 26, 2005 at 12:57:05PM +0100, Fergal Daly wrote: > > 1 the refs came from \&somefunc > > 2 the refs come from evaling strings of code > > 3 the refs are closures and therefore have some d

Re: is_deeply() and code refs

2005-06-27 Thread Fergal Daly
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

Re: is_deeply() and code refs

2005-06-27 Thread Fergal Daly
On 6/26/05, Michael G Schwern <[EMAIL PROTECTED]> wrote: > > For 3, it looks like B::Deparse does't handle the data at all so even > > if the deparsed subs are identical they may behave totally > > differently. > > This will simply have to be a caveat. Fortunately, if B::Deparse ever gets > this

Re: Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
On Mon, Jun 27, 2005 at 11:36:13AM +1000, [EMAIL PROTECTED] wrote: > >Another way to look at the "eval" case is to apply it to other references. > > > > is_deeply( eval "{ foo => 42, bar => 23 }", > >{ "bar", 42, "foo", 23 } ); > > > >Even though the code is written differently

Re: Re: is_deeply() and code refs

2005-06-26 Thread leif . eriksen
[EMAIL PROTECTED] wrote: Another way to look at the "eval" case is to apply it to other references. is_deeply( eval "{ foo => 42, bar => 23 }", { "bar", 42, "foo", 23 } ); Even though the code is written differently the resulting data is the same. Would anyone be

Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
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

Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
On Sun, Jun 26, 2005 at 12:57:05PM +0100, Fergal Daly wrote: > 1 the refs came from \&somefunc > 2 the refs come from evaling strings of code > 3 the refs are closures and therefore have some data associated with them > > For 3, it looks like B::Deparse does't handle the data at all so even > if t

Re: is_deeply() and code refs

2005-06-26 Thread Collin Winter
On 6/26/05, Fergal Daly <[EMAIL PROTECTED]> wrote: > You have 3 situations > > 1 the refs came from \&somefunc > 2 the refs come from evaling strings of code > 3 the refs are closures and therefore have some data associated with them > > For 3, it looks like B::Deparse does't handle the data at a

Re: is_deeply() and code refs

2005-06-26 Thread Smylers
David Landgren writes: > Michael Schwern wrote at the beginning of this thread: > > > What it *shouldn't* do is what Test.pm does, namely execute the > > code ref and compare the values returned. It would just compare > > the refernces. > > Why should it not do that? Is this because of subs

Re: is_deeply() and code refs

2005-06-26 Thread Fergal Daly
You have 3 situations 1 the refs came from \&somefunc 2 the refs come from evaling strings of code 3 the refs are closures and therefore have some data associated with them For 3, it looks like B::Deparse does't handle the data at all so even if the deparsed subs are identical they may behave tot

Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
On Sun, Jun 26, 2005 at 12:06:47PM +0200, David Landgren wrote: > > What it *shouldn't* do is what Test.pm does, namely execute the > > code ref and compare the values returned. It would just compare > > the refernces. > > Why should it not do that? Is this because of subs with side effects? > I

Re: is_deeply() and code refs

2005-06-26 Thread David Landgren
Tels wrote : -BEGIN PGP SIGNED MESSAGE- Moin, On Sunday 26 June 2005 07:18, Collin Winter wrote: [...] After tinkering with B::Deparse for a bit, I think this particular "oddity" may just be a result of poorly-written docs (or, more probably, poorly-read on my part). The module seems

Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
On Sun, Jun 26, 2005 at 01:18:42AM -0400, Collin Winter wrote: > With this matter sorted, I've started on the code > and requisite tests to make the new stuff work. Ok, let me know when you have something. -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern Reality is t

Re: is_deeply() and code refs

2005-06-26 Thread Michael G Schwern
On Sun, Jun 26, 2005 at 10:25:51AM +0200, Tels wrote: > > After tinkering with B::Deparse for a bit, I think this particular > > "oddity" may just be a result of poorly-written docs (or, more > > probably, poorly-read on my part). The module seems to do the right > > thing in all cases I could come

Re: is_deeply() and code refs

2005-06-26 Thread Tels
-BEGIN PGP SIGNED MESSAGE- Moin, On Sunday 26 June 2005 07:18, Collin Winter wrote: > > > My initial quick-glance at B::Deparse's documentation mentions > > > something about perl optimising certain constants away, which could > > > well throw a spanner into the works. Storable uses B::De

Re: is_deeply() and code refs

2005-06-25 Thread Collin Winter
> > My initial quick-glance at B::Deparse's documentation mentions > > something about perl optimising certain constants away, which could > > well throw a spanner into the works. Storable uses B::Deparse when > > serialising coderefs, though, so I'm certain there's a way around > > this. > > That

Re: is_deeply() and code refs

2005-06-25 Thread Michael G Schwern
On Sun, Jun 26, 2005 at 12:08:35AM -0400, Collin Winter wrote: > My inital strategy for implementing this was a two-tiered approach. > First, compare the references; if they're the same, return true, go no > futher. If they differ, however, say if anonymous subs were thrown > into the mix, then use

Re: is_deeply() and code refs

2005-06-25 Thread Collin Winter
I'll chime in, as I'm the one who initially raised the idea : ) I'll start with a use-case: my initial motivation for having is_deeply handle coderefs came up while building certain unit tests for a rewrite of DBD::Mock. Several of the worker functions return complex data structures -- which may c

is_deeply() and code refs

2005-06-25 Thread Michael G Schwern
Currently, throwing is_deeply() a code ref causes it to barf. perl -MTest::More -wle 'print is_deeply sub {}, sub {}' WHOA! No type in _deep_check This should never happen! Please contact the author immediately! # Looks like your test died before it could output anything. is_deeply() doesn't k