ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Re: Synopsis 4: Return type of a ~~ b
by Joe English other posts by this author
Aug 30 2004 7:25PM messages near this date
Re: Synopsis 4: Return type of a ~~ b | S5 tr concern
On Sat, Aug 28, 2004 at 01:30:47AM -0400, Joe Gottman wrote:
:     I just reread the table of smart matches in Synopsis 4, and I realized
: that it doesn't say what is returned by a ~~ b.  For example, the first line
: of this table says
: 
:  
: 
:   $_      $x        Type of Match Implied    Matching Code
: 
:     ======  =====     =====================    =============
: 
:     Any     Code<$>    scalar sub truth         match if $x($_)
: 
:  
: 
: This is fine when $_ ~~ $x is called in boolean context.  But what if the
: smart match operator is called in array or list context?   Does 
: 
: $_ ~~ $x 
: 
: then return the result of $x($_)?  I would expect that it does. After all,
: in Perl 5, the expression 
: 
:    $string =~ /(a+)(b+)/ 
: 
: returns a list of captured substrings in list context

If we apply the outer context to the right argument in the case of
/.../ (and I don't see why we shouldn't), then we could conceivably
do the same for $x($_) as well.  But in that case, why wouldn't you
just call $x($leftarg) yourself?

Larry
Thread:
Joe Gottman
Larry Wall
Joe English

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved