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
210
PPRとKeyword::Simpleと あとVariable::Declaration
Kenta Kobayashi
March 03, 2018
Tweet
Share
More Decks by Kenta Kobayashi
See All by Kenta Kobayashi
Perlの生きのこり - YAPC::Fukuoka 2025
kfly8
0
1.7k
プロジェクトの空気を読んで開発してくれるPerlのAIツールがほしい
kfly8
2
660
Perlの生きのこり - エンジニアがこの先生きのこるためのカンファレンス2025
kfly8
4
2.9k
Tシャツに書かれたコードを読む
kfly8
0
1.4k
Introduce Sub::Meta
kfly8
0
92
研修はイベントでなくコミュニティ作り
kfly8
0
2.1k
明日からできる新人のオンボーディングガイド
kfly8
0
870
メンター成長のためのふりかえり会
kfly8
0
1.4k
Interfaces in Perl5 at The Perl Conference 2019 in Pittsburgh
kfly8
0
3.2k
Other Decks in Technology
See All in Technology
小さく始めるBCP ― 多プロダクト環境で始める最初の一歩
kekke_n
1
390
~Everything as Codeを諦めない~ 後からCDK
mu7889yoon
3
320
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
540
【Oracle Cloud ウェビナー】[Oracle AI Database + AWS] Oracle Database@AWSで広がるクラウドの新たな選択肢とAI時代のデータ戦略
oracle4engineer
PRO
1
130
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
920
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
42k
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.3k
Introduction to Bill One Development Engineer
sansan33
PRO
0
360
What happened to RubyGems and what can we learn?
mikemcquaid
0
280
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
150
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
49
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
180
sira's awesome portfolio website redesign presentation
elsirapls
0
150
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
79
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
92
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
75
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
Exploring anti-patterns in Rails
aemeredith
2
250
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
100
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!!