develooper Front page | perl.perl6.language | Postings from July 2006

Re: Run time dispatch on ~~

Thread Previous | Thread Next
From:
Yuval Kogman
Date:
July 13, 2006 14:09
Subject:
Re: Run time dispatch on ~~
Message ID:
20060713210823.GI19536@woobling.org
On Thu, Jul 13, 2006 at 15:44:33 -0400, Aaron Sherman wrote:

> Now, let's look at some of the good that ~~ does for us:
> 
> 	$a ~~ "Some string" # sameness
> 	$a ~~ 5             # sameness
>         $a ~~ ->{...}       # test
>         $a ~~ /.../         # regex matching
> 
> That's great, and we don't want to mess with any of it.
> 
> But, then we have:
> 
> 	$a ~~ $b            # uh... something


One compelling reason to have them behave exactly the same is to
allow refactoring.

If i'm using the same pattern on several inputs i'd like to maybe
delegate this to a helper sub that will actually run the ~~ for me,
in some way, and i'd like 100% compatibility.

Also, sometimes i am matching on behalf of my caller, this is very
common in dispatch algorithms, or things like tree visitors:

	my @list = $tree.filter_children( $match ); # very generic and useful


-- 
  Yuval Kogman <nothingmuch@woobling.org>
http://nothingmuch.woobling.org  0xEBD27418


Thread Previous | Thread Next


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