develooper Front page | perl.perl6.language | Postings from June 2005

Re: caller and want

Thread Previous
From:
Gaal Yahas
Date:
June 12, 2005 06:19
Subject:
Re: caller and want
Message ID:
20050612131808.GC14133@sike.forum2.org
On Wed, Jun 08, 2005 at 12:20:57PM -0700, Larry Wall wrote:
> : I'm not sure how this selection mechanism is meant to be used.
> 
> The skip is meant to be applied after filtration.  Don't filter out
> things you want to see later, in other words.

Okay, caller done as r4555. Without :label for now, because we don't
have that yet.

> : - AES does not enumerate the complete member set. We can use that now :)
> 
> Um.  That's something I wouldn't mind delegating to whoever is slogging
> it out on the ground.

That's fine for caller, but half the examples for want imply things that
aren't available in Pugs' exisitng want yet (count, rw), and I think they
might not be straightforward to add. If there are other things come to
mind they'll probably be easier to add all at once.

[.sub -> .subname ; .sub returns coderef]
> That's the direction we're going with &?SUB and $?SUBNAME, so I don't
> see why it couldn't apply here too.
 
Done.

> It would be nice if the interfaces were similar where they try to do
> similar things.
> 
> But then, it might be nice to copy over the :nth($n) interface from
> pattern matching too, somehow or other.  Right now our selectors don't
> have a way to generalize that.  You almost want to be able to say
> something like caller(3rd(Sub)), which causes ~~ to match Sub, but
> only on the third thing that could be construed as a Sub, presuming
> ~~ is treating the other argument as some kind of iterator.  But up
> till now we've been treating such iterators as external to ~~, with
> the args matched one at a time.  One could imagine seeing things like:
> 
>     given =$IN {
> 	when 1st(/foo/)  {...}
> 	when 2nd(/bar/)  {...}
> 	when 3rd(/baz/)  {...}
>     }
> 
> but the semantics of such a construct are more than somewhat problematic.

Is caller so time-critical that saying 3rd(caller(Sub)) is too bad?

FWIW, this is how I interpreted caller(Sub, :skip<2>), as "the third
sub". And unless I'm wrong, caller(Block, :skip<2>, :label<moose>) would
mean, "once you get to the third Block, look on for one labeled "moose".
So we don't have a way to skip three methods and then look for a labeled
block, but if the user really wants that, let them grovel over a
complete call chain themselves.

-- 
Gaal Yahas <gaal@forum2.org>
http://gaal.livejournal.com/

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About