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
180
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.4k
Tシャツに書かれたコードを読む
kfly8
0
1.3k
Introduce Sub::Meta
kfly8
0
65
研修はイベントでなくコミュニティ作り
kfly8
0
2.1k
明日からできる新人のオンボーディングガイド
kfly8
0
830
メンター成長のためのふりかえり会
kfly8
0
1.3k
Interfaces in Perl5 at The Perl Conference 2019 in Pittsburgh
kfly8
0
3k
経験から効率よく学習する
kfly8
0
430
Interfaces in Perl5
kfly8
1
960
Other Decks in Technology
See All in Technology
GeminiとNotebookLMによる金融実務の業務革新
abenben
0
230
Snowflake Summit 2025 データエンジニアリング関連新機能紹介 / Snowflake Summit 2025 What's New about Data Engineering
tiltmax3
0
310
Кто отправит outbox? Валентин Удальцов, автор канала Пых
lamodatech
0
340
Uniadex__公開版_20250617-AIxIoTビジネス共創ラボ_ツナガルチカラ_.pdf
iotcomjpadmin
0
160
PHPでWebブラウザのレンダリングエンジンを実装する
dip_tech
PRO
0
200
Amazon S3標準/ S3 Tables/S3 Express One Zoneを使ったログ分析
shigeruoda
3
470
データプラットフォーム技術におけるメダリオンアーキテクチャという考え方/DataPlatformWithMedallionArchitecture
smdmts
5
630
Observability infrastructure behind the trillion-messages scale Kafka platform
lycorptech_jp
PRO
0
140
登壇ネタの見つけ方 / How to find talk topics
pinkumohikan
3
360
生成AIで小説を書くためにプロンプトの制約や原則について学ぶ / prompt-engineering-for-ai-fiction
nwiizo
3
1.3k
Witchcraft for Memory
pocke
1
300
AWS アーキテクチャ作図入門/aws-architecture-diagram-101
ma2shita
29
11k
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Faster Mobile Websites
deanohume
307
31k
Code Reviewing Like a Champion
maltzj
524
40k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Raft: Consensus for Rubyists
vanstee
140
7k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
490
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
670
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
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!!