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
クラウドサービス事業者におけるOSS
tagomoris
2
840
全文検索+セマンティックランカー+LLMの自然文検索サ−ビスで得られた知見
segavvy
2
110
トラシューアニマルになろう ~開発者だからこそできる、安定したサービス作りの秘訣~
jacopen
2
2k
CZII - CryoET Object Identification 参加振り返り・解法共有
tattaka
0
380
2.5Dモデルのすべて
yu4u
2
870
利用終了したドメイン名の最強終活〜観測環境を育てて、分析・供養している件〜 / The Ultimate End-of-Life Preparation for Discontinued Domain Names
nttcom
2
200
Raycast AI APIを使ってちょっと便利な拡張機能を作ってみた / created-a-handy-extension-using-the-raycast-ai-api
kawamataryo
0
100
『衛星データ利用の方々にとって近いようで触れる機会のなさそうな小話 ~ 衛星搭載ソフトウェアと衛星運用ソフトウェア (実物) を動かしながらわいわいする編 ~』 @日本衛星データコミニティ勉強会
meltingrabbit
0
150
レビューを増やしつつ 高評価維持するテクニック
tsuzuki817
1
730
地方拠点で エンジニアリングマネージャーってできるの? 〜地方という制約を楽しむオーナーシップとコミュニティ作り〜
1coin
1
230
「海外登壇」という 選択肢を与えるために 〜Gophers EX
logica0419
0
710
7日間でハッキングをはじめる本をはじめてみませんか?_ITエンジニア本大賞2025
nomizone
2
1.8k
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
A designer walks into a library…
pauljervisheath
205
24k
The Pragmatic Product Professional
lauravandoore
32
6.4k
How to train your dragon (web standard)
notwaldorf
91
5.8k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Done Done
chrislema
182
16k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Visualization
eitanlees
146
15k
Unsuck your backbone
ammeep
669
57k
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!!