On 13 December 2010 17:47, Abigail <abigail@abigail.be> wrote: > On Mon, Dec 13, 2010 at 05:26:29PM +0100, demerphq wrote: >> On 13 December 2010 17:09, Eric Brine <ikegami@adaelis.com> wrote: >> > On Mon, Dec 13, 2010 at 3:07 AM, Johan Vromans <jvromans@squirrel.nl> wrote: >> > >> >> [Quoting Eric Brine, on December 13 2010, 02:51, in "Re: [perl #80628] [P"] >> >> > On Mon, Dec 13, 2010 at 2:09 AM, Johan Vromans <jvromans@squirrel.nl> >> >> wrote: >> >> > >> >> > > More important is whether it is a keyword, or a compile time constant >> >> > > like __FILE__ and __LINE__. >> >> > > >> >> > > -- Johan >> >> > > >> >> > >> >> > As proposed, it's not constant. >> >> >> >> Then please do not call it __SUB__. >> >> >> >> What would be the difference with (caller(0))[3] ? >> >> >> > >> > caller[3] doesn't work for anon subs. >> > >> >> perl -E"sub { say( (caller(0))[3] ) }->()" >> > main::__ANON__ >> > >> > It was specifically proposed that __SUB__ would return a reference in at >> > least that case. >> >> It seen's to me that it MUST return a reference in ALL situations. > > I agree. Do one thing in one case, and another in another case doesn't seem > like a win situation to me. At least, not here. You certainly shouldn't > have to change the body of a sub if you change it from an anon sub to a > named one. And the fact that it not returning a reference would almost certainly lead to bugs. For instance the same kind of problem we see here: $ perl -MCarp -le'sub foo { confess "foo" } sub baz { confess "baz" } *bar=&foo; *foo=&baz; bar()' foo at -e line 1 main::foo called at -e line 1 If we returned anything but a code reference I reckon one could cook up something like this to cause a bunch of edge-case insanity. (Consider how much worse it gets when you add localized subroutines to the mix...) cheers, Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Previous | Thread Next