SlideShare a Scribd company logo
1 of 25
Download to read offline
6 things
about 6
NY.pm, 8 Dec 2016
ThePerlReview•www.theperlreview.com
6ThingsAbout6
perlmodules.net
ThePerlReview•www.theperlreview.com
6ThingsAbout6
Phasers
ThePerlReview•www.theperlreview.com
6ThingsAbout6
count = 0;
while ( … ) {
…
}
output "There were {count} items!";
ThePerlReview•www.theperlreview.com
6ThingsAbout6
use v6;
while( … ) {
state $count = 0;
LAST { put "There were $count" }
…
}
ThePerlReview•www.theperlreview.com
6ThingsAbout6 # Program execution
BEGIN { put "BEGIN, at compile time, ASAP" }
CHECK { put "CHECK, at compile time, ALAP" }
INIT { put "INIT, during main execution, ASAP" }
END { put "END, during main execution, ALAP" }
for 0 .. 3 -> $item {
my Int $square = $item ** 2;
# Block phasers
ENTER { put "tENTER block" }
LEAVE { put "tLEAVE block" }
KEEP { put "KEEP block: Got value $_" } # NYI
UNDO { put "ttUNDO block" }
PRE { put "PRE block ------" }
POST { put "POST block" }
# Loop phasers
FIRST { put "tFIRST loop" }
NEXT { put "tNEXT loop" }
LAST { put "tLAST loop"; put "**** LOOP is done ****" }
}
https://www.learningperl6.com/2016/11/30/quick-tip-15-phasers/
ThePerlReview•www.theperlreview.com
6ThingsAbout6
Sets
ThePerlReview•www.theperlreview.com
6ThingsAbout6
$ perl6
> my $set = set( qw/ 5 cat dog 37 / )
set(37, 5, cat, dog)
> "5" ∈ $set
True
> 5 ∈ $set
False
> "5" (elem) $set
True
ThePerlReview•www.theperlreview.com
6ThingsAbout6
$ perl6
> my $set_a = set qw/ a b c /;
set(a, c, b)
> my $set_b = set qw/ c d e /;
set(c, e, d)
> $set_a ∪ $set_b
set(a, c, b, e, d)
> $set_a ∩ $set_b
set(c)
> $set_a ∖ $set_b
set(a, b)
> $set_a ⊖ $set_b
set(a, b, e, d)
ThePerlReview•www.theperlreview.com
6ThingsAbout6
Sequences
ThePerlReview•www.theperlreview.com
6ThingsAbout6
1, 2 … 10 # 1 to 10
1, 3 … 10 # odds
1, 5 … 10 # 1,5,9
1, 2 … * # infinite, lazy
1, 3 … * # odds
1, 5 … * # 1,5,9
1, 1, -> $n,$m {$n+$m} … *
1, 1, { $^a + $^b } … *
1, 1, * + * … *
ThePerlReview•www.theperlreview.com
6ThingsAbout6
Types
ThePerlReview•www.theperlreview.com
6ThingsAbout6
> my Int $i = 137
137
> my Int $j = 22/7
Type check failed in assignment to $j;
expected Int but got Rat (<22/7>)
ThePerlReview•www.theperlreview.com
6ThingsAbout6
> my Int @array = ( 1, 2, 3, 4 )
[1 2 3 4]
> my Int @array = qw/ 1 2 3 4 /
Type check failed in assignment to @array;
expected Int but got Str ("1")
ThePerlReview•www.theperlreview.com
6ThingsAbout6
> my Int %hash{Str}
{}
> %hash{ "Butterflies" } = 137
137
> %hash{ "Llamas" } = "Huh?"
Type check failed in binding to assignval;
expected Int but got Str ("Huh?")
> %hash{ 5 } = 1
Type check failed in binding to key;
expected Str but got Int (5)
ThePerlReview•www.theperlreview.com
6ThingsAbout6
my package EXPORT::DEFAULT {
...
subset Pos of Real where * > 0;
subset Neg of Real where * < 0;
subset Zero of Real where * == 0;
subset UNumeric of Real where * >= 0;
subset Even of Int where * % 2 == 0;
subset Odd of Int where * % 2;
}
https://github.com/bradclawsie/Subsets-Common
ThePerlReview•www.theperlreview.com
6ThingsAbout6
subset ZInt of Cool is export where {
state ( $min, $max ) =
%names.keys.sort( { $^a <=> $^b } ).[0,*-1];
( $_.truncate == $_ and $min <= $_ <= $max )
or
note "Expected a known atomic number between $min and $max"
and
False;
};
https://github.com/briandfoy/perl6-chemistry-elements
ThePerlReview•www.theperlreview.com
6ThingsAbout6
MAIN
ThePerlReview•www.theperlreview.com
6ThingsAbout6
sub MAIN ( $n, $m ) {
put "N: $n M: $m";
}
$ perl6 main.p6
Usage:
main.p6 <n> <m>
ThePerlReview•www.theperlreview.com
6ThingsAbout6
sub MAIN ( $n, $m = 5 ) {
put "N: $n M: $m";
}
$ perl6 main.p6
Usage:
main.p6 <n> [<m>]
ThePerlReview•www.theperlreview.com
6ThingsAbout6
sub MAIN ( Int $n, Int $m ) {
put "N: $n M: $m";
}
sub MAIN (
Int $n where * > 0,
Int $m where * < 0
) {
put "N: $n M: $m";
}
ThePerlReview•www.theperlreview.com
6ThingsAbout6
multi MAIN (
Int $n where * > 0,
Int $m where * < 0
) {
put "PosNeg => N: $n M: $m";
}
multi MAIN (
Int $n where * > 0,
Int $m where * > 0
) {
put "PosPos => N: $n M: $m";
}
ThePerlReview•www.theperlreview.com
6ThingsAbout6
Grammars
ThePerlReview•www.theperlreview.com
6ThingsAbout6
grammar Legal::Module::Name
{
token TOP
{
^ <identifier> [<separator><identifier>] ** 0..* $
}
token identifier
{ # leading alpha or _ only
<[A..Za..z_]>
<[A..Za..z0..9]> ** 0..*
}
token separator
{
:: # colon pairs
}
}
my $match_obj = Legal::Module::Name.parse($s);
http://perltricks.com/article/144/2015/1/13/How-to-create-a-grammar-in-Perl-6/
ThePerlReview•www.theperlreview.com
6ThingsAbout6
Questions

More Related Content

What's hot

Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
brian d foy
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
Tatsuhiko Miyagawa
 

What's hot (20)

I, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 OverlordsI, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 Overlords
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tie
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
 
SPL, not a bridge too far
SPL, not a bridge too farSPL, not a bridge too far
SPL, not a bridge too far
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
 
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみたR版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
 
TDDBC お題
TDDBC お題TDDBC お題
TDDBC お題
 
Storytelling By Numbers
Storytelling By NumbersStorytelling By Numbers
Storytelling By Numbers
 
Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)Learning Perl 6 (NPW 2007)
Learning Perl 6 (NPW 2007)
 
10 Catalyst Tips
10 Catalyst Tips10 Catalyst Tips
10 Catalyst Tips
 
Session8
Session8Session8
Session8
 

Viewers also liked

The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Community
brian d foy
 

Viewers also liked (10)

Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6
 
Create and upload your first Perl module to CPAN
Create and upload your first Perl module to CPANCreate and upload your first Perl module to CPAN
Create and upload your first Perl module to CPAN
 
I ❤ CPAN
I ❤ CPANI ❤ CPAN
I ❤ CPAN
 
Tour of the Perl docs
Tour of the Perl docsTour of the Perl docs
Tour of the Perl docs
 
The Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian TransformThe Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian Transform
 
Making My Own CPAN
Making My Own CPANMaking My Own CPAN
Making My Own CPAN
 
Making My Own CPAN
Making My Own CPANMaking My Own CPAN
Making My Own CPAN
 
The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Community
 
Perl Conferences for Beginners
Perl Conferences for BeginnersPerl Conferences for Beginners
Perl Conferences for Beginners
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014
 

Similar to 6 things about perl 6

201412 seccon2014 オンライン予選(英語) write-up
201412 seccon2014 オンライン予選(英語) write-up201412 seccon2014 オンライン予選(英語) write-up
201412 seccon2014 オンライン予選(英語) write-up
恵寿 東
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
jhchabran
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Propel sfugmd
Propel sfugmdPropel sfugmd
Propel sfugmd
iKlaus
 

Similar to 6 things about perl 6 (20)

Hidden treasures of Ruby
Hidden treasures of RubyHidden treasures of Ruby
Hidden treasures of Ruby
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in Optimization
 
FizzBuzzではじめるテスト
FizzBuzzではじめるテストFizzBuzzではじめるテスト
FizzBuzzではじめるテスト
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
Úvod do programování 5
Úvod do programování 5Úvod do programování 5
Úvod do programování 5
 
Dropping ACID with MongoDB
Dropping ACID with MongoDBDropping ACID with MongoDB
Dropping ACID with MongoDB
 
201412 seccon2014 オンライン予選(英語) write-up
201412 seccon2014 オンライン予選(英語) write-up201412 seccon2014 オンライン予選(英語) write-up
201412 seccon2014 オンライン予選(英語) write-up
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding Horrors
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday Developer
 
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)Dip Your Toes in the Sea of Security (ConFoo YVR 2017)
Dip Your Toes in the Sea of Security (ConFoo YVR 2017)
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
3. javascript bangla tutorials
3. javascript bangla tutorials3. javascript bangla tutorials
3. javascript bangla tutorials
 
Open Source Search: An Analysis
Open Source Search: An AnalysisOpen Source Search: An Analysis
Open Source Search: An Analysis
 
Propel sfugmd
Propel sfugmdPropel sfugmd
Propel sfugmd
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic traps
 

More from brian d foy (9)

Conferences for Beginners presentation
Conferences for Beginners presentationConferences for Beginners presentation
Conferences for Beginners presentation
 
20 years in Perl
20 years in Perl20 years in Perl
20 years in Perl
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPAN
 
Backward to DPAN
Backward to DPANBackward to DPAN
Backward to DPAN
 
Perl docs {sux|rulez}
Perl docs {sux|rulez}Perl docs {sux|rulez}
Perl docs {sux|rulez}
 
Why I Love CPAN
Why I Love CPANWhy I Love CPAN
Why I Love CPAN
 
What's wrong with the perldocs
What's wrong with the perldocsWhat's wrong with the perldocs
What's wrong with the perldocs
 
Frozen Perl 2011 Keynote
Frozen Perl 2011 KeynoteFrozen Perl 2011 Keynote
Frozen Perl 2011 Keynote
 
brian d foy
brian d foybrian d foy
brian d foy
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

6 things about perl 6