Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Perl 6 Junctions and Postgres SQL

by rhesa (Vicar)
on Dec 22, 2007 at 01:36 UTC ( [id://658592]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl 6 Junctions and Postgres SQL
in thread Perl 6 Junctions and Postgres SQL

Toying with perl 5.10:
perl -E 'for(1..20) { when([18..23]) { say } }'
:-)

I'm slightly puzzled that I couldn't write when(18..23), though.

Replies are listed 'Best First'.
Re^4: Perl 6 Junctions and Postgres SQL
by TimToady (Parson) on Dec 22, 2007 at 17:45 UTC
    I'm slightly puzzled that I couldn't write when(18..23), though.
    If you're used to Perl 6 switches, you're going to notice breakages in Perl 5 switches because Perl 5 doesn't natively support types such as Range or Junction, nor does it automatically promote a list in scalar context to an array. Instead, it tends to throw away information.

    And arguably the Perl 5 behavior with an array is wrong (or would be wrong in Perl 6); in P6 arrays are matched as a whole, and you must use something like any() to match against any element of an array (see the section on Smart Matching in Synopsis 3). Range objects in P6 are matched directly against their endpoints though, so you don't have to convert to a list and then use any(). In essence, P5 smart matching cannot really emulate P6 smart matching because P5 doesn't have the type system to support it transparently.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://658592]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found