Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PPRとKeyword::Simpleと あとVariable::Declaration

PPRとKeyword::Simpleと あとVariable::Declaration

Kenta Kobayashi

March 03, 2018
Tweet

More Decks by Kenta Kobayashi

Other Decks in Technology

Transcript

  1. PPR

  2. PPR example use PPR; my $s = 'my $yapc:OKINAWA =

    "OIST"'; print $s =~ m{ ((?&PerlAttributes)) $PPR::GRAMMAR }x; # => :OKINAWA
  3. Keyword::Simple example package ExampleKeywordSimple; use Keyword::Simple; sub import { Keyword::Simple::define

    'yapc' => sub { my $ref = shift; substr($$ref, 0, 0) = 'print " はいさい!";sub'; }; } 1; use ExampleKeywordSimple; yapc okinawa { } # => はいさい!
  4. Keyword::Simple pros/cons Pure Perl で Perl を弄れる(2 回目) B::Deparse が手放せない(

    主観) use ExampleKeywordSimple; BEGIN { $^H{'Keyword::Simple/keywords'} = 'HASH(0x7fc1b940a018)' } ; ; print " はいさい!"; sub okinawa { BEGIN { $^H{'Keyword::Simple/keywords'} = 'HASH(0x7fc1b940a018)' } }
  5. Variable::Declaration example use Variable::Declaration; use Types::Standard qw/Int/; let Int $foo

    = 2018; $foo = 'YAPC'; # ERROR: Value "YAPC" did not pass type constraint "Int"
  6. deparse example use Variable::Declaration; use Types::Standard ('Int'); use feature 'state';

    BEGIN { $^H{'Keyword::Simple/keywords'} = 'HASH(0x7fc8de02e350)' } ; ; my $foo = 2018; croak(Int->get_message($foo)) unless Int->check($foo); ttie $foo, Int; $foo = 'YAPC';