--- Smylers <[EMAIL PROTECTED]> wrote:
> David Storrs wrote:
> 
> > On Fri, Jan 03, 2003 at 10:58:49AM -0800, Mr. Nobody wrote:
> >
> > > --- Smylers <[EMAIL PROTECTED]> wrote:
> > > 
> > > > junction should be sufficient:
> > > > 
> > > >   print "date" if $var == any(1 .. 31);
> > > 
> > > Superpositions in the core? You're kidding, right?
> 
> Yeah, somehow they just slipped right in there without anybody on this
> mailing list really noticing -- and certainly without any long threads
> discussing the syntax for their operator incarnations and the knock-on
> effect that could have on other operators ...

I looked through the p6l archives, there really wasn't much discussion about
it.

> > What's wrong with "if 1 <= $var <= 31"?
> > 
> > ...nothing.  If you like it, by all means use it.  But, (1) TIMTOWTDI,
> > (2) Smyler's version is more visually concise (although, granted, it
> > actually takes a few extra chars), (3) Smyler's version puts the
> > variable (the important thing in the expression) on the left instead
> > of the in the middle, and (4) IMHO, Smyler's version reads better as
> > English.

It's also far slower. Constructing a 31-element list, junctionizing it, then
testing against each element vs. 2 numeric comparisons. I know where my money
is...

> Those are stylistic things, and to some degree a matter of taste.  More
> importantly the junction version -- or even better, the smartmatch
> version as pointed out by Chris Dutton -- work for arbitrary sets, not
> just ranges of consecutive values.

Wanting to do this for arbitrary lists dosen't need junctions. "if grep $_ ==
$var, @mylist" suffices.

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Reply via email to