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
p5-Lodash!
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kenta Kobayashi
May 26, 2018
Technology
890
2
Share
p5-Lodash!
吉祥寺.pm #14 / LT
Kenta Kobayashi
May 26, 2018
More Decks by Kenta Kobayashi
See All by Kenta Kobayashi
Perlの生きのこり - YAPC::Fukuoka 2025
kfly8
0
2k
プロジェクトの空気を読んで開発してくれるPerlのAIツールがほしい
kfly8
2
840
Perlの生きのこり - エンジニアがこの先生きのこるためのカンファレンス2025
kfly8
4
3k
Tシャツに書かれたコードを読む
kfly8
0
1.5k
Introduce Sub::Meta
kfly8
0
98
研修はイベントでなくコミュニティ作り
kfly8
0
2.3k
明日からできる新人のオンボーディングガイド
kfly8
0
890
メンター成長のためのふりかえり会
kfly8
0
1.4k
Interfaces in Perl5 at The Perl Conference 2019 in Pittsburgh
kfly8
0
3.3k
Other Decks in Technology
See All in Technology
AIが盛んな時代に 技術記事を書き始めて起きた私の中での小さな変化
peintangos
0
120
Shipping AI Agents — Lessons from Production
vvatanabe
0
280
スクラムの中で AI-DLC workflow を 使い始めて3ヶ月の振り返り
kaminashi
0
130
レビューしきれない?それは「全て人力でのレビュー」だからではないでしょうか
amixedcolor
0
350
CloudTrail を見つめ直してみる
kazzpapa3
1
120
Claude Code を安全に使おう勉強会 / Claude Code Security Basics
masahirokawahara
12
36k
扱える不確実性を増やしていく - スタートアップEMが考える「任せ方」
kadoppe
0
320
The Journey of Box Building
tagomoris
4
3.4k
Cortex Codeのコスト見積ヒントご紹介
yokatsuki
0
110
AI와 협업하는 조직으로의 여정
arawn
0
510
20260423_執筆の工夫と裏側 技術書の企画から刊行まで / From the planning to the publication of technical book
nash_efp
3
440
基盤を育てる 外部SaaS連携の運用
gamonges_dresscode
1
120
Featured
See All Featured
Marketing to machines
jonoalderson
1
5.2k
ラッコキーワード サービス紹介資料
rakko
1
3.1M
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
200
How STYLIGHT went responsive
nonsquared
100
6.1k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
140
Building Flexible Design Systems
yeseniaperezcruz
330
40k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
130
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
190
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Transcript
p5-Lodash! 吉祥寺.pm14 / LT @k y8
_.defaults({ 'a': 1 }, { 'a': 3, 'b': 2 });
// → { 'a': 1, 'b': 2 } _.partition([1, 2, 3, 4], n => n % 2); // → [[1, 3], [2, 4]]
p5-Lodash Perl5 port of Lodash.js 同じ挙動を目指してる ( ひとまず) 手書き Inline
module に頼るでなく、 真正面から モチベー ション JSer に楽してもらいたい CPAN に便利なモジュー ルがたくさんあるけ ど、 知らないが為に損することもある
use Lodash; _->defaults({ a => 1 }, { a =>
3, b => 2 }); # → { a => 1, b => 2 } _->partition([1, 2, 3, 4], sub ($n) { $n % 2 }); # → [[1, 3], [2, 4]]
use Lodash qw(_defaults _partition); _defaults({ a => 1 }, {
a => 3, b => 2 }); # → { a => 1, b => 2 } _partition([1, 2, 3, 4], sub ($n) { $n % 2 }); # → [[1, 3], [2, 4]]
use Lodash -core; # => export core functions
_.add
6 + 4
❯ perl -e 'print 6 + 4' 10 ❯ node
-e 'console.log(6+4)' 10
'6' + '4'
❯ perl -e "print '6' + '4'" 10 ❯ node
-e "console.log('6'+'4')" 64
_.add(6, 4) # => 10 _.add('6', '4') # => '64'
❯ perl -MDevel::Peek -e "Dump 6" SV = IV(0x7fdf7d011370) at
0x7fdf7d011380 REFCNT = 1 FLAGS = (IOK,READONLY,PROTECT,pIOK) IV = 6
❯ perl -MDevel::Peek -e "Dump '6'" SV = PV(0x7fb986803e80) at
0x7fb98700a998 REFCNT = 1 FLAGS = (POK,IsCOW,READONLY,PROTECT,pPOK) PV = 0x7fb986500b70 "6"\0 CUR = 1 LEN = 10 COW_REFCNT = 0
どちらも Scalar Value だけど、 中身は違う 一方は、 Integer Value もう一方は Pointer
Value 6 と '6' の中身の違いを浮き出せれば、 区別できる
use B;
use Test::More; use B; ok B::svref_2object(\6)->FLAGS & B::SVp_IOK; ok not
B::svref_2object(\'6')->FLAGS & B::SVp_IOK; done_testing;
None
XOR operator
use Test::More; ok((6^6) eq '0'); ok not (('6'^'6') eq '0');
done_testing;
use Test::More; # NUL ok not ((6^6) eq "\0"); ok(('6'^'6')
eq "\0"); done_testing;
sub is_number { my $value = shift; looks_like_number($value) && ($value^$value)
eq '0' }
None
!!1
is_number(!!1^!!1) # => ok ❯ perl -MDevel::Peek -e 'Dump !!1^!!1'
SV = IV(0x7f93e7015370) at 0x7f93e7015380 REFCNT = 1 FLAGS = (PADTMP,IOK,READONLY,PROTECT,pIOK) IV = 0
None
❯ perl -MDevel::Peek -e 'Dump !!1' SV = PVNV(0x7ff3a4001010) at
0x10d9b7b58 REFCNT = 2147483644 FLAGS = (IOK,NOK,POK,READONLY,PROTECT,pIOK,pNOK,pPOK) IV = 1 NV = 1 PV = 0x10d99cd43 "1" CUR = 1 LEN = 0
PVNV!
PVNV dual value Scalar::Util::isdual
sub is_number { my $value = shift; looks_like_number($value) && ($value^$value)
eq '0' && !isdual($value) }
None
雑まとめ p5-Lodash の話から Perl の話に脱線 SV は、 多態 コンテキストで、 値が変わる
見ようと思えば、 中身も見れる Devel::Peek B.pm etc
進捗
7/256
やっていき
Gotanda.pm #18 6/11( 月) 株式会社メルカリ 六本木! スピー カー @kazeburo 「System
Programming and Perl」
ぱー るもんがー ごたぴー きちぴー ぜんぶがいねん ( 字余り)