SlideShare a Scribd company logo
1 of 21
Common Boolean Class
for Perl 5
Kenichi Ishigaki
@charsbar
TPC in Glasgow 2018
Aug 16, 2018
me
• DBD::SQLite
• CPANTS
• PAUSE on Mojolicious
• JSON/JSON::PP
• Text::CSV/Text::CSV_PP
Boolean is really simple
It has only two states:
TRUE or FALSE
Boolean in Perl 5 is not
that simple
Because we don't have native boolean
Typical implementation of
boolean in Perl 5
my $true = 1;
my $false = 0;
$T = bless $true, $boolean_class;
$F = bless $false, $boolean_class;
(with some overload configuration)
What if a "boolean" object
is embedded in a string?
• use overload to convert them into
"true" or "false"?
• ... if "$false"; # but true
• say "This is " .
($bool->isa($boolean_class)
? ($bool ? "true" : "false")
: $bool); # ugly
How can you tell if
it's a boolean?
• MetaCPAN returns 1877 results
when you search "Bool"...
• Not all of them represent
boolean, though...
Don't worry too much
All of them should work in
the Perl context, at least
as long as you use them in
the boolean context
Until you start
serializing your data
JSON modules only accept
JSON::PP::Boolean objects
(or their aliases) by default
Luckily JSON::PP::Boolean
is in Perl 5 core now
• You can use it as a default
boolean class
• Do you want to use JSON::PP
just to get boolean objects?
How about boolean.pm?
• It would have been nice if it were
more widely adopted
• Unfortunately it is not supported
by JSON modules by default
Or Types::Serialiser?
• It provides boolean objects that are
JSON::PP::Boolean
• It has a more neutral name for CBOR::XS
• It's not in core, so it's hard to adopt for
toolchain modules or the likes
Then what to do?
• Add something into core?
• Or just use the same
convention under the hood?
• Or else?
The bottomline
• The new stuff should work
with existing modules
• Otherwise you can't use it
for interoperability
Two new candidates
bool.pm
• Written by Tina Mueller as a
proof of concept at PTS 2018
• Not yet CPANized
https://github.com/perlpunk/bool-p5/tree/json-pp-compat
Types::Bool
• Written by Adriano Ferreira,
inspired by Tina's PTS report
• Works quite similar to
Types::Serialiser
https://metacpan.org/pod/Types::Bool
There are still issues
to be solved
• bool namespace and Perl 6?
• Types:: namespace is reserved
for a different purpose?
• duplicated effort?
• and probably more
Further reading
• "My report of the Perl Toolchain Summit
2018 in Oslo" by Tina Mueller
http://blogs.perl.org/users/tinita/2018/05/my-report-of-the-
perl-toolchain-summit-2018-in-oslo.html
• "[Work in Progress] Boolean support with
Types::Bool"
https://github.com/makamaka/JSON-PP/pull/36
Let us know
your thoughts
Thanks

More Related Content

More from charsbar

2018年夏のPerl5
2018年夏のPerl52018年夏のPerl5
2018年夏のPerl5charsbar
 
萬國之津梁
萬國之津梁萬國之津梁
萬國之津梁charsbar
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codecharsbar
 
2017年夏のPerl
2017年夏のPerl2017年夏のPerl
2017年夏のPerlcharsbar
 
2017年春のPerl
2017年春のPerl2017年春のPerl
2017年春のPerlcharsbar
 
Json(::PP) is a-changing
Json(::PP) is a-changingJson(::PP) is a-changing
Json(::PP) is a-changingcharsbar
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)charsbar
 
JSON, JSON::PP, and more
JSON, JSON::PP, and moreJSON, JSON::PP, and more
JSON, JSON::PP, and morecharsbar
 
perl language update
perl language updateperl language update
perl language updatecharsbar
 
CPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したいCPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したいcharsbar
 
2013年のCPANモジュール作成事情
2013年のCPANモジュール作成事情2013年のCPANモジュール作成事情
2013年のCPANモジュール作成事情charsbar
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPANcharsbar
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLitecharsbar
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS charsbar
 
Analyze CPAN, Analyze Community
Analyze CPAN, Analyze CommunityAnalyze CPAN, Analyze Community
Analyze CPAN, Analyze Communitycharsbar
 
Annual Report 2012
Annual Report 2012Annual Report 2012
Annual Report 2012charsbar
 
DBD::SQLite
DBD::SQLiteDBD::SQLite
DBD::SQLitecharsbar
 
CPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its toolsCPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its toolscharsbar
 
CPANTS 2012
CPANTS 2012CPANTS 2012
CPANTS 2012charsbar
 
Revisiting ppm
Revisiting ppmRevisiting ppm
Revisiting ppmcharsbar
 

More from charsbar (20)

2018年夏のPerl5
2018年夏のPerl52018年夏のPerl5
2018年夏のPerl5
 
萬國之津梁
萬國之津梁萬國之津梁
萬國之津梁
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 code
 
2017年夏のPerl
2017年夏のPerl2017年夏のPerl
2017年夏のPerl
 
2017年春のPerl
2017年春のPerl2017年春のPerl
2017年春のPerl
 
Json(::PP) is a-changing
Json(::PP) is a-changingJson(::PP) is a-changing
Json(::PP) is a-changing
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)
 
JSON, JSON::PP, and more
JSON, JSON::PP, and moreJSON, JSON::PP, and more
JSON, JSON::PP, and more
 
perl language update
perl language updateperl language update
perl language update
 
CPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したいCPANの依存モジュールをもう少し正しく検出したい
CPANの依存モジュールをもう少し正しく検出したい
 
2013年のCPANモジュール作成事情
2013年のCPANモジュール作成事情2013年のCPANモジュール作成事情
2013年のCPANモジュール作成事情
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS
 
Analyze CPAN, Analyze Community
Analyze CPAN, Analyze CommunityAnalyze CPAN, Analyze Community
Analyze CPAN, Analyze Community
 
Annual Report 2012
Annual Report 2012Annual Report 2012
Annual Report 2012
 
DBD::SQLite
DBD::SQLiteDBD::SQLite
DBD::SQLite
 
CPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its toolsCPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its tools
 
CPANTS 2012
CPANTS 2012CPANTS 2012
CPANTS 2012
 
Revisiting ppm
Revisiting ppmRevisiting ppm
Revisiting ppm
 

Recently uploaded

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 

Recently uploaded (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 

Common boolean class_for_perl5

  • 1. Common Boolean Class for Perl 5 Kenichi Ishigaki @charsbar TPC in Glasgow 2018 Aug 16, 2018
  • 2. me • DBD::SQLite • CPANTS • PAUSE on Mojolicious • JSON/JSON::PP • Text::CSV/Text::CSV_PP
  • 3. Boolean is really simple It has only two states: TRUE or FALSE
  • 4. Boolean in Perl 5 is not that simple Because we don't have native boolean
  • 5. Typical implementation of boolean in Perl 5 my $true = 1; my $false = 0; $T = bless $true, $boolean_class; $F = bless $false, $boolean_class; (with some overload configuration)
  • 6. What if a "boolean" object is embedded in a string? • use overload to convert them into "true" or "false"? • ... if "$false"; # but true • say "This is " . ($bool->isa($boolean_class) ? ($bool ? "true" : "false") : $bool); # ugly
  • 7. How can you tell if it's a boolean? • MetaCPAN returns 1877 results when you search "Bool"... • Not all of them represent boolean, though...
  • 8. Don't worry too much All of them should work in the Perl context, at least as long as you use them in the boolean context
  • 9. Until you start serializing your data JSON modules only accept JSON::PP::Boolean objects (or their aliases) by default
  • 10. Luckily JSON::PP::Boolean is in Perl 5 core now • You can use it as a default boolean class • Do you want to use JSON::PP just to get boolean objects?
  • 11. How about boolean.pm? • It would have been nice if it were more widely adopted • Unfortunately it is not supported by JSON modules by default
  • 12. Or Types::Serialiser? • It provides boolean objects that are JSON::PP::Boolean • It has a more neutral name for CBOR::XS • It's not in core, so it's hard to adopt for toolchain modules or the likes
  • 13. Then what to do? • Add something into core? • Or just use the same convention under the hood? • Or else?
  • 14. The bottomline • The new stuff should work with existing modules • Otherwise you can't use it for interoperability
  • 16. bool.pm • Written by Tina Mueller as a proof of concept at PTS 2018 • Not yet CPANized https://github.com/perlpunk/bool-p5/tree/json-pp-compat
  • 17. Types::Bool • Written by Adriano Ferreira, inspired by Tina's PTS report • Works quite similar to Types::Serialiser https://metacpan.org/pod/Types::Bool
  • 18. There are still issues to be solved • bool namespace and Perl 6? • Types:: namespace is reserved for a different purpose? • duplicated effort? • and probably more
  • 19. Further reading • "My report of the Perl Toolchain Summit 2018 in Oslo" by Tina Mueller http://blogs.perl.org/users/tinita/2018/05/my-report-of-the- perl-toolchain-summit-2018-in-oslo.html • "[Work in Progress] Boolean support with Types::Bool" https://github.com/makamaka/JSON-PP/pull/36
  • 20. Let us know your thoughts