Share
Embed
Transcript
66 slides
-
me 2016年のPerl@LLoT Perl in 2016@YAPC::Hokkaido 2017年春のPerl@YAPC::Kansai 2017年夏のPerl@YAPC::Fukuoka (萬國之津梁@YAPC::Okinawa) (2018年初夏のPerl5)@Hokkaido.pm #14
2018年夏のPerl5@Shibuya.pm #18 2018年残暑のPerl@LL2018 2019年冬のPerl@YAPC::Tokyo (Learn Languages 2021) 2023年春のPerl@YAPC::Kyoto 2024年冬のPerl@YAPC::Hiroshima <- イマココ -
Perl Steering Council 2023年8月にメンバーの入れ替えがありました • Graham Knop (new) • Paul
Evans • Philippe Bruhat -
背景事情 欧米でサイバーセキュリティ関連の法整備が進んでいる • EO 14028 (2021/05) • NIS2 Directive &
Cyber Resilience Act 「CPANをもっと安全にしておかないといろいろヤバイ」 CPAN Security Working Group (2023/04) https://security.metacpan.org -
HTTP::Tinyを利用している小物ツール CPANモジュールだけでも400件以上 • App::cpanoutdated • App::pmuninstall • Pod::PerldocJp • OrePAN2
• Slack::Notify • Slack::WebHook https://metacpan.org/module/HTTP::Tiny/requires -
Perl本体のセキュリティリリース 2023年11月に5.38.2、5.36.3、5.34.3が出ました • CVE-2023-47038 - Write past buffer end via
illegal user-defined Unicode property • CVE-2023-47039 - Perl for Windows binary hijacking vulnerability -
クラス Perl本体でもクラスの実装が始まっています use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)
{ field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } } -
クラス 新しいキーワードはclass、field、method(と未実装のrole)のみ use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)
{ field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } } -
クラス 属性を多用するようになっています use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)
{ field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } } -
クラス method内の$selfなどは自動的に用意されます use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)
{ field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } } -
クラス サブルーチンシグネチャにも対応 use v5.38; use experimental 'class'; class CPANAuthor :isa(Person)
{ field $pause_id :param; method name_and_id () { return $self->name . " ($pause_id)"; } method upload ($distribution) { ... } } -
サブルーチンシグネチャのデフォルト値 従来はパラメータが渡らなかった場合のみ use v5.20; use experimental 'signatures'; sub point ($x,
$y = 10) { say "($x, $y)"; } point(20); # (20, 10) -
サブルーチンシグネチャのデフォルト値 undefが渡ってくると補完できません use v5.20; use experimental 'signatures'; sub point ($x,
$y = 10) { say "($x, $y)"; } point(20, undef); # (20, ) point($x, $y); -
サブルーチンシグネチャのデフォルト値 //=を使うと期待通りの動作になります use v5.38; sub point ($x, $y //= 10)
{ say "($x, $y)"; } point(20); # (20, 10) point(20, undef); # (20, 10) -
フィールドのデフォルト値 クラスのフィールドも同様です class Log { field $message :param; field $level
:param //= 'INFO'; } -
builtin::export_lexically 特定のブロックのみにエクスポートできる 機能が用意されました package My::Util; use v5.38; use experimental qw(builtin);
sub import { my $class = shift; my %export = map { $_ => $class->can($_) // die "Can't export $_" } @_; builtin::export_locally %export; } sub foo { say "foo" } -
builtin::export_lexically 範囲外のところには取り込んだ関数は残っていません { use My::Util qw(foo); foo(); # foo }
foo(); # Undefined subroutine &main::foo called -
module_true バージョンバンドルなどを利用してこの機能を有効にしておくと、 モジュールの末尾に真値を入れなくてもよくなります package Foo; use v5.38; # または use
feature qw(module_true); sub foo { ... } # ここに真値を入れなくてもよくなります -
プラガブル中置演算子 中置演算子を拡張できるようになりました use v5.38; use Syntax::Operator::Equ; if ($x equ $y)
{ ... } if ($i === $j) { ... } -
スマートマッチとgiven/when 代替となりうるSyntax::Keyword::Matchの 実験は進められています use v5.38; use Syntax::Keyword::Match; use Syntax::Operator::Equ; match
($str : equ) { case (undef) { say "not defined" } case ("") { say "defined but empty" } default { say "not empty" } } -
未定義パッケージからの(un)import (5.39.1) ファイルの大文字小文字を無視する環境での事故防止策 use v5.39.1; no Warning 'redefine'; # require
Warning; Warning->unimport('redefine'); -
__CLASS__ キーワード (5.39.2) $selfが使えない場所で使うと便利? class Foo { use constant DEFAULT_X
=> 10; field $x = __CLASS__->DEFAULT_X; method say_x { say $x } } class Bar :isa(Foo) { use constant DEFAULT_X => 20; } Foo->new->say_x; # 10 Bar->new->say_x; # 20 -
__CLASS__ キーワード (5.39.2) methodはインスタンスからは呼べないので要注意 class Foo { field $x =
__CLASS__->default_x; # ERROR! method default_x { 10 } method say_x { say $x } } class Bar :isa(Foo) { method default_x { 20 } } -
builtin::load_module (5.39.5) builtinに実験的な機能としてload_module関数が追加されました use v5.39.5; use builtin 'load_module'; use experimental
'builtin'; for my $module (keys $config->{prereq}->%*) { load_module $module; } -
builtin::load_module (5.39.5) バージョン指定はVERSIONメソッドで use v5.39.5; use builtin 'load_module'; use experimental
'builtin'; for my $module (keys $config->{prereq}->%*) { load_module $module; if (my $version = $config->{prereq}{$module}) { $module->VERSION($version); } } -
returnと間接オブジェクト (5.39.6) なんでもないコードに見えますが… use v5.38; use List::Util 'sum'; sub my_sum
{ return sum grep $_ > 0, @_ } say my_sum(-1, 2, 3); # 5 -
returnと間接オブジェクト (5.39.6) sumを取り込み忘れると、おかしなことに use v5.38; # use List::Util 'sum'; sub
my_sum { return sum grep $_ > 0, @_ } say my_sum(-1, 2, 3); # *main::sum23 -
returnと間接オブジェクト (5.39.6) no bareword::filehandlesでも止められません (used only onceの警告が出るようにはなります) use v5.38; no
bareword::filehandles; # use List::Util 'sum'; sub my_sum { return sum grep $_ > 0, @_ } say my_sum(-1, 2, 3); # *main::sum23 -
returnと間接オブジェクト (5.39.6) 5.39.6からは構文エラーになります use v5.39.6; # use List::Util 'sum'; sub
my_sum { return sum grep $_ > 0, @_ } say my_sum(-1, 2, 3); -
特殊変数の別名 うっかり読み込むと正規表現が遅くなってしまう Englishモジュールの代わりに local ${^ARG}; # $_ my $pid =
${^PID}; # $$ my $error = ${^EVAL_ERROR}; # $@ my %signals = %{^SIG}; # %SIG https://github.com/Perl/PPCs/blob/main/ppcs/ppc0014-english-aliases.md -
文字列テンプレート "foo @{[$bar->baz]}"のようなハックはありますが… # No interpolation qt{Greetings}; # Simple scalar
interpolation qt<Greetings, {$title} {$name}>; # Interpolation of method calls qt"Greetings, {$user->title} {$user->name}"; # Interpolation of various expressions qt{It has been {$since{n}} {$since{units}} since your last login}; qt{...a game of {join q{$"}, $favorites->{game}->name_words->@*}}; https://github.com/Perl/PPCs/blob/main/ppcs/ppc0019-qt-string.md -
条件付き矢印演算子 左辺が定義済みなら普通の矢印演算子、 未定義ならそこで処理を打ち切り全体をないものに # $val = defined $foo && defined
$foo->{bar} ? $foo->{bar}[3] : (); $val = $foo?->{bar}?->[3]; # @vals = defined $aref ? $aref->@* : (); @vals = $aref?->@*; # note that @vals is (), not (undef). # my $class = 'SomeClass'; $class->new if defined $class; my $class = 'SomeClass'; $class?->new; https://github.com/Perl/PPCs/blob/main/ppcs/ppc0021-optional-chaining-operator.md -
メタプログラミング metaモジュールを使った実験が始まっています use v5.14; use meta; my $metapkg = meta::get_package(
"MyApp::Some::Package" ); $metapkg->add_symbol( '&a_function' => sub { say "New function was created" } ); MyApp::Some::Package::a_function(); https://metacpan.org/pod/meta https://github.com/Perl/PPCs/blob/main/ppcs/ppc0022-metaprogramming.md -
「実験」≠「未完成」 • 新しい機能は実験から • 事前に十分な議論はされているはず • 単に動くかどうかを試しているわけではない • 皆が気に入るかどうかを試している •
実際に試して、(PPCsの議論を踏まえた) フィードバックを -
ツールチェーンのサポート下限 従来はPerl 5.8.1(2003/09)が下限でした https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md Lancaster Consensus (2013) Going forward, the
Perl toolchain will target Perl 5.8.1, released September 2003. This will allow toolchain modules to reliably use PerlIO and improved Unicode support. -
ツールチェーンのサポート下限 2023年4月のToolchain Summitで改正されました Lyon Amendment (2023) https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lyon-amendment.md No new release
of a distribution in the Perl toolchain will specify a minimum perl prerequisite version (whether configure, build, runtime, or test) that has been available for less than ten years. 「リリース後10年未満のPerlをサポート下限とすることはない」 -
ツールチェーンのサポート下限 • いまは例外的に2012年リリースのPerl 5.16をサポート • 2024年6月にRHEL/CentOS 7が退役したら、 2014年リリースの5.20より古いPerlへのインストールは 保証されなくなっていきます •
今後は毎年無条件に上がっていくので、 CIなどで旧版のサポートをするときは要注意 • 古いPerlには古いバージョンのモジュールをインストール できるようにするという話も出てはいますが… -
ツールチェインに限らず… すでに何人かの方がサポート下限のバージョンなどを 上げ始めています • IO::Socket::IP (5.14) • Test::Deep (5.12) •
Email::Simple (5.12) • Plack (5.12) • DBD::mysql (5.001からはMySQL 5系がサポート外に) -
その頃Rakuは… • Rigaで予定されていたカンファレンスは中止 (後にオンライン開催) • 6.eはいつ? • 6.cは2015年 • 6.dは2020年
• そろそろ…という話は出ている模様 • RakuASTの実装中 • Raku Core Summit (2023/06) -
2024年の主要Perl関連イベント • German Perl/Raku-Workshop (4/15~17, Frankfurt, Germany) https://www.perl-workshop.de • Perl
Toolchain Summit 2024 (4/25~28, Lisbon, Portugal) • The Perl and Raku Conference 2024 (6/25~27, Las Vegas, NV) https://tprc.us/tprc-2024-las/