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
190
PPRとKeyword::Simpleと あとVariable::Declaration
Kenta Kobayashi
March 03, 2018
Tweet
Share
More Decks by Kenta Kobayashi
See All by Kenta Kobayashi
Perlの生きのこり - エンジニアがこの先生きのこるためのカンファレンス2025
kfly8
4
2.6k
Tシャツに書かれたコードを読む
kfly8
0
1.4k
Introduce Sub::Meta
kfly8
0
74
研修はイベントでなくコミュニティ作り
kfly8
0
2.1k
明日からできる新人のオンボーディングガイド
kfly8
0
850
メンター成長のためのふりかえり会
kfly8
0
1.3k
Interfaces in Perl5 at The Perl Conference 2019 in Pittsburgh
kfly8
0
3.1k
経験から効率よく学習する
kfly8
0
440
Interfaces in Perl5
kfly8
1
980
Other Decks in Technology
See All in Technology
ソースを読むプロセスの例
sat
PRO
15
9.7k
SCONE - 動画配信の帯域を最適化する新プロトコル
kazuho
1
310
JSConf JPのwebsiteをGatsbyからNext.jsに移行した話 - Next.jsの多言語静的サイトと課題
leko
2
180
初めてのDatabricks Apps開発
taka_aki
1
240
個人でデジタル庁の デザインシステムをVue.jsで 作っている話
nishiharatsubasa
1
110
CREが作る自己解決サイクルSlackワークフローに組み込んだAIによる社内ヘルプデスク改革 #cre_meetup
bengo4com
0
260
「最速」で Gemini CLI を使いこなそう! 〜Cloud Shell/Cloud Run の活用〜 / The Fastest Way to Master the Gemini CLI — with Cloud Shell and Cloud Run
aoto
PRO
0
140
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
310
データ戦略部門 紹介資料
sansan33
PRO
1
3.8k
「REALITY」3Dアバターシステムの7年分の拡張の歴史について
gree_tech
PRO
0
120
Microsoft 365 の認証と承認を理解する / Understanding Microsoft 365 Authentication and Authorization
karamem0
0
110
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3k
Featured
See All Featured
Designing for Performance
lara
610
69k
Being A Developer After 40
akosma
91
590k
Keith and Marios Guide to Fast Websites
keithpitt
411
23k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
A designer walks into a library…
pauljervisheath
209
24k
Building an army of robots
kneath
306
46k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
Site-Speed That Sticks
csswizardry
13
920
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.1k
How STYLIGHT went responsive
nonsquared
100
5.8k
Automating Front-end Workflow
addyosmani
1371
200k
The World Runs on Bad Software
bkeepers
PRO
72
11k
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!!