SlideShare a Scribd company logo
Perl

   2011/02/26
@NagoyaRubyKaigi02
    id:clairvy
•
• PHP / Java / Git / Subversion
  • Zsh + Screen + Emacs + Eclipse
• Nagoya.pm / CSNagoya
• Mixi          PS
メタプログラミングPerl nagoya rubykaigi02
“Ruby
                                 Rubyists


                          ?
                   Ruby
                                   ”



http://blog.livedoor.jp/dankogai/archives/51507869.html
“



           ”



      97
26-
•
• PHP / Java / Git / Subversion
 • Zsh + Screen + Emacs + Eclipse
• Nagoya.pm / CSNagoya
•Mixi          PS
Perl
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
•


    (Wikipedia -   )

•
•
•
•
•
•
1   (ry
Monday
メタプログラミングPerl nagoya rubykaigi02
in Ruby
Object   #Object


        C        #C


        D        #D


obj   #obj
メタプログラミングPerl nagoya rubykaigi02
Simple
in Perl
>   >
obj   Roles   Parents
obj   Roles   Parents
Multiple Inheritance
P11   P12       P21    P21




      P1          P2



            C
class P11 {
   method f {print " P11"} };
(     )
class C is P1 is P2 {
   method f {print "C"} };

my $obj = C.new;
$obj.+f;
# => C P1 P11 P12 P2 P21 P22
Tuesday
メタプログラミングPerl nagoya rubykaigi02
class Str
   def to_an
      gsub /[^ws]/, ''
   end
end
puts ‘a*10?’.to_an
# => ‘a10’
use MONKEY_TYPING;
augment class Str {
   method to_an {
      my $s = self;
      $s ~~ s:g/<-alnum-space>+//;
      return $s; }}
say ‘a*10?’;
# => ‘a10’
use MONKEY_TYPING;
augment class Str {
   method to_an {
      my $s = self;
      $s ~~ s:g/<-alnum-space>+//;
      return $s; }}
say ‘a*10?’;
# => ‘a10’
メタプログラミングPerl nagoya rubykaigi02
Wednesday
メタプログラミングPerl nagoya rubykaigi02
^add_method
○ Class, Role
  × Object
Role
obj = []
def obj.f
  puts 'called f'
end
obj.f
# => ‘called f’
my @obj;
my $role = RoleHOW.new;
$role.^add_method(‘f’,
  my method f { say ‘called f’ });
$role.^compose;
@obj does $role;
@obj.f;
# => ‘called f’
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
class C; end
def C.cm
   puts ‘cm’
end
puts C.cm
# => ‘cm’
class C {
   method cm ($self :defined :) {
       say ‘cm’
   }
}
C.cm
# => ‘cm’
メタプログラミングPerl nagoya rubykaigi02
Thursday
メタプログラミングPerl nagoya rubykaigi02
Long
•function
• define
• lambda
• defun
• proc
Long
•function
• define
• lambda
• defun
• proc
middle

•fun
• def
• {}
• -> { }
middle

•fun
• def
• {}
• -> { }
Too short
メタプログラミングPerl nagoya rubykaigi02
sample
zero = lambda{|f|lambda{|x|x}}
addone = lambda{|m|
   lambda{|f|lambda{|x|f.call(m.call(f).call(x))}}}
one = addone.call(zero)
plus = lambda{|m, n|
   lambda{|f|lambda{|x|m.call(f).call(n.call(f).call(x))}}}
two = plus.call(one, one)
three = plus.call(two, one)

inc = lambda{|x|x+1}
puts ‘zero = ‘ + zero.call(inc).call(0).to_s
puts ‘one = ‘ + one.call(inc).call(0).to_s
puts ‘two = ‘ + two.call(inc).call(0).to_s
puts ‘three = ‘ + three.call(inc).call(0).to_s
my $zero = ->$f{->$x{$x}};
my $addone = ->$n{->$f{->$x{$f($n($f)($x))}}};
my $one = $addone($zero);
my $add = ->$m,$n{->$f{->$x{$m($f)($n($f)($x))}}};
my $two = $add($one, $one);
my $three = $add($two, $one);

my $inc = {$^n+1};
say 'zero = ', $zero($inc)(0);
say 'one = ', $one($inc)(0);
say 'two = ', $two($inc)(0);
say 'three = ', $three($inc)(0);
Friday
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
for 0..Inf -> $i {
   say $i;
   last if $i > 17; }
Saturday
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
TMTOWTDI
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
in Nagoya
(   )
•        Scala (Scala)

• Has (Haskell)
• Proof Cafe (Coq)
• Nagoya.lisp (lisp)
• OCaml-Nagoya (OCaml)
And
Nagoya.pm(   )
Nagoya.pm( )
メタプログラミングPerl nagoya rubykaigi02
メタプログラミングPerl nagoya rubykaigi02
Perl
λ
メタプログラミングPerl nagoya rubykaigi02
Any Questions?
メタプログラミングPerl nagoya rubykaigi02
Perl6
• http://perl-users.jp/articles/advent-calendar/
  2010/perl6/
• http://d.hatena.ne.jp/uasi/searchdiary?
  word=*[Perl6]
• http://perlgeek.de/en/article/5-to-6
• https://github.com/clairvy/
  metaprogramming_ruby
メタプログラミングPerl nagoya rubykaigi02

More Related Content

PDF
Why my Go program is slow?
DOCX
DOCX
Doubly linklist
PDF
Loss Monitor
ODP
Functional perl
PDF
اسلاید دوم جلسه پنجم کلاس پایتون برای هکرهای قانونی
PPT
Introduction to Perl
PDF
Go a crash course
Why my Go program is slow?
Doubly linklist
Loss Monitor
Functional perl
اسلاید دوم جلسه پنجم کلاس پایتون برای هکرهای قانونی
Introduction to Perl
Go a crash course

What's hot (19)

PPTX
Type script in practice
PDF
Short intro to the Rust language
PDF
Quill - 一個 Scala 的資料庫存取利器
PPT
Number
PDF
「Pit」で救う世界
PPTX
Lessons learned from functional programming
PDF
2016 gunma.web games-and-asm.js
PPTX
JavaScript Event Loop
PDF
Om (Cont.)
PDF
Web app development_php_06
PPT
Jan 2012 HUG: RHadoop
PPTX
Introduction to F# for the C# developer
PDF
Graphql with Flamingo
PDF
20151224-games
PDF
Kotlin Backstage
PDF
Shapes and calculate (area and contour) / C++ oop concept
PDF
Implementing Software Machines in Go and C
PDF
Introduction to go
PDF
Let's golang
Type script in practice
Short intro to the Rust language
Quill - 一個 Scala 的資料庫存取利器
Number
「Pit」で救う世界
Lessons learned from functional programming
2016 gunma.web games-and-asm.js
JavaScript Event Loop
Om (Cont.)
Web app development_php_06
Jan 2012 HUG: RHadoop
Introduction to F# for the C# developer
Graphql with Flamingo
20151224-games
Kotlin Backstage
Shapes and calculate (area and contour) / C++ oop concept
Implementing Software Machines in Go and C
Introduction to go
Let's golang
Ad

Similar to メタプログラミングPerl nagoya rubykaigi02 (20)

PDF
Ruby Language - A quick tour
PDF
Ruby 程式語言入門導覽
KEY
Module Magic
PPTX
Ruby data types and objects
KEY
An introduction to Ruby
KEY
PDF
Ruby — An introduction
PDF
Ruby Programming Introduction
PPT
Ruby programming introduction
KEY
Ruby AST Tools
PPTX
Ruby -the wheel Technology
PPTX
Introduction to Ruby’s Reflection API
PPT
name name2 n2.ppt
PPT
name name2 n
PPT
name name2 n2
PPT
name name2 n
PPT
ppt18
PPT
ppt9
PPT
ppt7
PPT
ppt30
Ruby Language - A quick tour
Ruby 程式語言入門導覽
Module Magic
Ruby data types and objects
An introduction to Ruby
Ruby — An introduction
Ruby Programming Introduction
Ruby programming introduction
Ruby AST Tools
Ruby -the wheel Technology
Introduction to Ruby’s Reflection API
name name2 n2.ppt
name name2 n
name name2 n2
name name2 n
ppt18
ppt9
ppt7
ppt30
Ad

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
A Presentation on Artificial Intelligence
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Electronic commerce courselecture one. Pdf
PPTX
sap open course for s4hana steps from ECC to s4
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25-Week II
A Presentation on Artificial Intelligence
MIND Revenue Release Quarter 2 2025 Press Release
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Programs and apps: productivity, graphics, security and other tools
The Rise and Fall of 3GPP – Time for a Sabbatical?
Mobile App Security Testing_ A Comprehensive Guide.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Review of recent advances in non-invasive hemoglobin estimation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Electronic commerce courselecture one. Pdf
sap open course for s4hana steps from ECC to s4

メタプログラミングPerl nagoya rubykaigi02

Editor's Notes