Re: dis-junctive patterns

2005-11-22 Thread TSa

HaloO,

Gaal Yahas wrote:

In pugs, r7961:

 my @pats = /1/, /2/;
 say MATCH if 1 ~~ any @pats; # MATCH
 say MATCH if 0 ~~ any @pats; # no match

So far so good. But:

 my $junc = any @pats;
 say MATCH if 1 ~~ $junc; # no match
 say MATCH if 0 ~~ $junc; # no match

Bug? Feature?


Ohh, interesting. This reminds me to my proposal
that junctions are code types and exert their magic
only when recognized as such. The any(@pats) form
constructs such a code object right in the match while
the $junc var hides it. My idea was to explicitly
request a code evaluation by one of

  my junc = any @pats; # 1: use code sigil
  say MATCH if 1 ~~ junc;

  say MATCH if 1 ~~ do $junc; # 2: do operator

  say MATCH if 1 ~~ $junc();  # 3: call operator

But this might just be wishful thinking on my side.
--


Re: dis-junctive patterns

2005-11-22 Thread Larry Wall
On Tue, Nov 22, 2005 at 09:31:27AM +0200, Gaal Yahas wrote:
: In pugs, r7961:
: 
:  my @pats = /1/, /2/;
:  say MATCH if 1 ~~ any @pats; # MATCH
:  say MATCH if 0 ~~ any @pats; # no match
: 
: So far so good. But:
: 
:  my $junc = any @pats;
:  say MATCH if 1 ~~ $junc; # no match
:  say MATCH if 0 ~~ $junc; # no match
: 
: Bug? Feature?

Feels like a bug to me.  The junction should autothread the ~~ even if ~~
weren't dwimmy.  And ~~ ought to be dwimmy about junctions even if they
didn't autothread.  Maybe they're just doing the hallway dance.

Larry


dis-junctive patterns

2005-11-21 Thread Gaal Yahas
In pugs, r7961:

 my @pats = /1/, /2/;
 say MATCH if 1 ~~ any @pats; # MATCH
 say MATCH if 0 ~~ any @pats; # no match

So far so good. But:

 my $junc = any @pats;
 say MATCH if 1 ~~ $junc; # no match
 say MATCH if 0 ~~ $junc; # no match

Bug? Feature?

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/