Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PPRとKeyword::Simpleと あとVariable::Declaration
Search
Kenta Kobayashi
March 03, 2018
Technology
0
160
PPRとKeyword::Simpleと あとVariable::Declaration
Kenta Kobayashi
March 03, 2018
Tweet
Share
More Decks by Kenta Kobayashi
See All by Kenta Kobayashi
Tシャツに書かれたコードを読む
kfly8
0
1.2k
Introduce Sub::Meta
kfly8
0
49
研修はイベントでなくコミュニティ作り
kfly8
0
1.2k
明日からできる新人のオンボーディングガイド
kfly8
0
790
メンター成長のためのふりかえり会
kfly8
0
1.2k
Interfaces in Perl5 at The Perl Conference 2019 in Pittsburgh
kfly8
0
2.9k
経験から効率よく学習する
kfly8
0
280
Interfaces in Perl5
kfly8
1
930
p5-Lodash!
kfly8
2
800
Other Decks in Technology
See All in Technology
関東Kaggler会LT: 人狼コンペとLLM量子化について
nejumi
3
590
Goで作って学ぶWebSocket
ryuichi1208
1
1.1k
「海外登壇」という 選択肢を与えるために 〜Gophers EX
logica0419
0
710
バックエンドエンジニアのためのフロントエンド入門 #devsumiC
panda_program
18
7.5k
ユーザーストーリーマッピングから始めるアジャイルチームと並走するQA / Starting QA with User Story Mapping
katawara
0
210
組織貢献をするフリーランスエンジニアという生き方
n_takehata
1
1.3k
ホワイトボードチャレンジ 説明&実行資料
ichimichi
0
130
2.5Dモデルのすべて
yu4u
2
870
30分でわかる『アジャイルデータモデリング』
hanon52_
9
2.7k
開発スピードは上がっている…品質はどうする? スピードと品質を両立させるためのプロダクト開発の進め方とは #DevSumi #DevSumiB / Agile And Quality
nihonbuson
2
3k
Building Products in the LLM Era
ymatsuwitter
10
5.5k
表現を育てる
kiyou77
1
210
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.2k
Scaling GitHub
holman
459
140k
The Pragmatic Product Professional
lauravandoore
32
6.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
10
1.3k
Faster Mobile Websites
deanohume
306
31k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
174
51k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
Speed Design
sergeychernyshev
27
790
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Transcript
PPR と Keyword::Simple と あと Variable::Declaration YAPC::Okinawa 2018 / LT
@k y8
k y8 2 歳の娘の父になった モバファク JPA
agenda 1. PPR 2. Keyword::Simple 3. Variable::Declaration
PPR
PPR Perl の静的解析モジュー ル 類似モジュー ルは、PPI 正規表現を使った、 解析ができる Statement,Variable,Block,etc
PPR example use PPR; my $s = 'my $yapc:OKINAWA =
"OIST"'; print $s =~ m{ ((?&PerlAttributes)) $PPR::GRAMMAR }x; # => :OKINAWA
PPR pros/cons 意図はわかりやすく、 簡潔 意図通りに作るのが難しい( 主観) Perl が柔軟すぎて
Keyword::Simple
Keyword::Simple Pure Perl で Perl にキー ワー ド追加できる PL_keyword_plugin を利用
類似モジュー ル Devel::Declare Keyword::Declare
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 { } # => はいさい!
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)' } }
PPR × Keyword::Simple Pure Perl で Perl を静的解析した結果を用いて Perl を拡張できる
Variable::Declaration
Variable::Declaration PPR × Keyword::Simple 変数宣言の拡張 use Type::Tie use Data::Lock
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"
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';
Variable::Declaration pros/cons buggy ( v0.01 ) 静的型付き言語を使えば? と言われる
Thanks!!