Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
PPRとKeyword::Simpleと あとVariable::Declaration
Kenta Kobayashi
March 03, 2018
Technology
0
82
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
550
Introduce Sub::Meta
kfly8
0
32
研修はイベントでなくコミュニティ作り
kfly8
0
680
明日からできる新人のオンボーディングガイド
kfly8
0
480
メンター成長のためのふりかえり会
kfly8
0
700
Interfaces in Perl5 at The Perl Conference 2019 in Pittsburgh
kfly8
0
2.2k
経験から効率よく学習する
kfly8
0
200
Interfaces in Perl5
kfly8
1
560
p5-Lodash!
kfly8
2
650
Other Decks in Technology
See All in Technology
220628 「Google AppSheet」タスク管理アプリをライブ作成 吉積情報伊藤さん
comucal
PRO
0
210
今どきのLinux事情
tokida
30
24k
eBPF for Security Observability
lizrice
0
150
Design for Humans: How to make better modernization decisions
indualagarsamy
2
120
The application of formal methods in Kafka reliability engineering
line_developers
PRO
1
160
DOM Invader - prototype pollution対応の衝撃 - / DOM Invader - prototype pollution
okuken
0
150
GeoLocationAnchor and MKTileOverlay
toyship
0
110
ROS再入門-はじめてのSLAM-
miura55
0
400
ひとりでも安定して 組織を変える活動を続けていくための ストレスマネジメント
pastelinc
0
850
OpsJAWS Meetup21 システム運用アンチパターンのすすめ
yoshiiryo1
0
1.4k
Custom AppをIP制限ありのままで審査に通す方法
yusuga
0
680
【Pythonデータ分析勉強会#33】「DearPyGuiに入門しました」の続き~Image-Processing-Node-Editor~
kazuhitotakahashi
0
140
Featured
See All Featured
Design by the Numbers
sachag
271
17k
Three Pipe Problems
jasonvnalue
89
8.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
29
4.3k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
11
4.7k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
7
1.1k
It's Worth the Effort
3n
172
25k
Facilitating Awesome Meetings
lara
29
4k
Product Roadmaps are Hard
iamctodd
34
6.5k
What's new in Ruby 2.0
geeforr
336
30k
In The Pink: A Labor of Love
frogandcode
131
21k
Testing 201, or: Great Expectations
jmmastey
21
5.4k
4 Signs Your Business is Dying
shpigford
169
20k
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!!