SlideShare a Scribd company logo
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年夏のPerl5
charsbar
 
萬國之津梁
萬國之津梁萬國之津梁
萬國之津梁
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 code
charsbar
 
2017年夏のPerl
2017年夏のPerl2017年夏のPerl
2017年夏のPerl
charsbar
 
2017年春のPerl
2017年春のPerl2017年春のPerl
2017年春のPerl
charsbar
 
Json(::PP) is a-changing
Json(::PP) is a-changingJson(::PP) is a-changing
Json(::PP) is a-changing
charsbar
 
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 more
charsbar
 
perl language update
perl language updateperl language update
perl language update
charsbar
 
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 CPAN
charsbar
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
charsbar
 
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 Community
charsbar
 
Annual Report 2012
Annual Report 2012Annual Report 2012
Annual Report 2012
charsbar
 
DBD::SQLite
DBD::SQLiteDBD::SQLite
DBD::SQLite
charsbar
 
CPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its toolsCPANTS: Kwalitative website and its tools
CPANTS: Kwalitative website and its tools
charsbar
 
CPANTS 2012
CPANTS 2012CPANTS 2012
CPANTS 2012charsbar
 
Revisiting ppm
Revisiting ppmRevisiting ppm
Revisiting ppm
charsbar
 

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

Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 

Recently uploaded (20)

Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 

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