Ruby2.7の新機能で簡易版Rubyインタプリタを実装してみる
by
fuqda
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Ruby2.7ͷ৽ػೳͰ ؆қ൛RubyΠϯλϓϦλΛ ࣮ͯ͠ΈΔ 2019/05/09 Hello hey for Engineers vol.3ɹɹ fuqda(fuqda90)
Slide 2
Slide 2 text
fuqdaͱਃ͠·͢ ʲܦྺʳ 4*FS ϲ݄ ͔Β ແڅΠϯλʔϯϲ݄Λܦͯ 4503&4KQྲྀΕண͖ ʲͦͷଞʳ ීஈ5BNBSCͱ͍͏ ଟຎҬ ٢ࣉʙീԦࢠ·Ͱ ͷ Ҭ3VCZίϛϡχςΟΛɹ ओ࠵ͯ͠·͢
Slide 3
Slide 3 text
ࠂ ݸਓత
Slide 4
Slide 4 text
݄ʹ5BNBSCͰ ΧϯϑΝϨϯε Γ·͢✨
Slide 5
Slide 5 text
ςʔϚʮRubyistͱͯ͠ͷʯ
Slide 6
Slide 6 text
Tama Rubyձٞ01 d ҙࢀՃͷ࠙ձd·Ͱ !ौ୩ηϧϦΞϯλϫʔ' (.0:PVST جௐߨԋɿҏ౻३Ұ͞Μ !KODIJUP جௐߨԋɿޒेཛྷ໌͞Μ !JHBJHB ͦͷଞ$'1ʴ5BNBSCϝϯόʔ-5
Slide 7
Slide 7 text
CFPઈࢍडதͰ͢ (ҰൠࢀՃืू6݄։࢝༧ఆ) https://tama-rb.github.io/tamarubykaigi01/
Slide 8
Slide 8 text
ࠓͷ͓
Slide 9
Slide 9 text
Ruby2.7ͷύλʔϯϚονΛ ࢼͯ͠ΈΔͱ͍͏ 3VCZͷτϥϯΫ NBTUFS ʹ 1BUUFSO.BUDIJOHͱ͍͏৽ػೳ͕ Ճ͞Ε͍ͯΔͱͷ͜ͱ ͱ͍͏Θ͚Ͱʂຊ ͦΕΛࢼͯ͠Έ·͢
Slide 10
Slide 10 text
ิɿRubyKaigi2019Ͱͷ ൃදͪ͜Β https://speakerdeck.com/k_tsj/pattern-matching-new-feature-in-ruby-2-dot-7
Slide 11
Slide 11 text
ࠓճ ύλʔϯϚονϯάΛ ࢼ͢ࡐ
Slide 12
Slide 12 text
3VCZͰ࡞Δ ؆қ൛ 3VCZΠϯλϓϦλ ✨
Slide 13
Slide 13 text
ʲલఏʳ ͜͜Ͱ࡞ΔΠϯλϓϦλʹ͍ͭͯɺ िץΞεΩʔͰ࿈ࡌ͞Ε͍ͯͨ (2016.09~2017.01) RubyͰֶͿRubyͷίʔυΛҰ෦ྲྀ༻͠ɺ ͦ͜ʹखΛೖΕ͍ͯ͘ܗͰ ਐΊ͍͖ͯ·͢ refs :ʮୈ5ճ RubyͰม͖ిΛ࡞ͬͯΈΔʯ https://ascii.jp/elem/000/001/230/1230449/
Slide 14
Slide 14 text
ͦͦΠϯλϓϦλͬͯ… JUFSQSFUFSˠҙຯɿʮ௨༁ʯ ਓ͕ؒॻ͍ͨιʔείʔυΛ ಡΈࠐΜͰϓϩάϥϜͱͯ͠ ࣮ߦ͢ΔϓϩάϥϜͷ͜ͱ
Slide 15
Slide 15 text
ྫ͑͜ΜͳࣜΛಡΈࠐΜͰ ΠϯλʔϓϦλ͕ղऍ͢Δ߹
Slide 16
Slide 16 text
ΠϯλϓϦλ͕ Δ͜ͱͬͯʁ
Slide 17
Slide 17 text
ࣈ۟ղੳ ߏจղੳ ࣮ߦ
Slide 18
Slide 18 text
1. ࣈ۟ղੳ จࣈྻΛͭͭ෦ͷྻʹม͢Δ
Slide 19
Slide 19 text
2. ߏจղੳ ϓϩάϥϜͱ࣮ͯ͠ߦՄೳͳߏจʹม͢Δ
Slide 20
Slide 20 text
3. ࣮ߦ ߏจΛೖྗͱͯ͠ϓϩάϥϜΛ࣮ߦ͢Δ
Slide 21
Slide 21 text
ࣈ۟ղੳ ߏจղੳ ࣮ߦ ࣌ؒͷ߹ʹΑΓ ͷ ෦ग़དྷ߹͍ͷϥΠϒϥϦΛ ྲྀ༻͠·͢
Slide 22
Slide 22 text
͍ͬͯ͘
Slide 23
Slide 23 text
ࠓճͷࡐྉᶃ ߏจղੳ༻ͷgem NJOSVCZ https://github.com/mame/minruby
Slide 24
Slide 24 text
ࠓճͷࡐྉᶄ ߏจΛRubyͱ࣮ͯ͠ߦ͢ΔΫϥε ࣮ߦ͢ΔϑΝΠϧ JOUFSQSFUFSSC
Slide 25
Slide 25 text
ࠓճͷࡐྉᶅ ߏจΛ࡞ΔͨΊͷܭࢉࣜΛهࡌͨ͠Ϋϥε ίϚϯυ࣮ߦ͢ΔϑΝΠϧͷҾͱͳΔϑΝΠϧ ʮʯ͕هࡌ͞Ε͍ͯΔ͚ͩ GPSNVMBSC
Slide 26
Slide 26 text
͡Ό࣮͋ࡍɺ 3VCZͷύλʔϯϚονϯάΛ ΠϯλϓϦλͷॲཧͰ͏ͱͯ͠ɺ ͲΜͳ෦Ͱ͑ΔͩΖ͏ʁ
Slide 27
Slide 27 text
ߟ͑ͯΈΔ
Slide 28
Slide 28 text
case~whenΛεοΩϦॻ͘ ͨΊʹ͏ͷͲ͏ͩΖ͏ʁ ɹɹɹɹ ߏจղੳޙͷྻ Λ ࠶ؼతʹݕࡧͯ͠Լهͷϝιουͷ 3VCZͱͯ͠ ࣮ߦ͢Δ෦ʹ खΛೖΕͯΈΔ
Slide 29
Slide 29 text
ࢼͯ͠ΈΑ͏
Slide 30
Slide 30 text
ࠓճ͏ ύλʔϯϚονϯάͷ छྨ ɹɹɹɹ˞ύλʔϯϚονϯάͷه๏ʹ ɹɹɹɹ͍͔ͭ͘ͷόϦΤʔγϣϯ͕͋Γ·͢
Slide 31
Slide 31 text
As Pattern DBTFʹ͕ͬͨ ύλʔϯʹҰக͢Δͱ Ұகͨ͠ͱ Ҏ߱ͷมΛ ඥ͚ͮΔ͜ͱ͕ग़དྷΔ
Slide 32
Slide 32 text
ͦͷଞͷύλʔϯϚονϯάʹ͍ͭͯ 7BMVF1BUUFSO 7BSJBCMF1FUUFSO "MUFSOBUJWF1BUUFSO "SSBZ1BUUFSO )BTI1BUUFSO ͪ͜Βͷهࣄ͕͔Γ͔ͬͨ͢ͷͰؾʹͳΔํͦͪΒ !NBLJDBNFMʮ3VCZͷ৽ػೳ1BUUFSO.BUDIJOH͕࠷ߴͰͨ͠ʯ IUUQTRJJUBDPNNBLJDBNFMJUFNTDEFGEFEC
Slide 33
Slide 33 text
ͬͯΈͨ
Slide 34
Slide 34 text
As PatternΛ͏લޙͷมߋࠩ ࠓճͷέʔεͰ࠶ؼॲཧΛॻ͔ͳͯ͘Α͘ͳΓ·ͨ͠ ଟগγϡοͱॻ͚͔ͨ͠Ε·ͤΜɻ ͬͱ៉ྷʹॻ͚ΔͩΖ͏͚Ͳࠓճΰϝϯͳ͍͞ʜ
Slide 35
Slide 35 text
खݩͰಈ͔͢߹ ͠खݩͰࢼͯ͠Έ͍ͨ ͱ͍͏ํHJTUʹιʔεΛ ஔ͍͓͖ͯ·ͨ͠ͷͰɺ ͦͪΒͰ͓ܰ͘ࢼ͚͠·͢ ) Rubyͷόʔδϣϯ2.7.0devͰ͢ https://gist.github.com/Shigeyuki-fukuda/37c2e9da1ac3744ea24920dacd25580f
Slide 36
Slide 36 text
࣮ࡍʹಈ͔ͨ݁͠Ռ SBJMTSVOOFSίϚϯυʹҾΛͯ͠ ࣮ߦͯ͠Έͨͱ͜ΖΩϟϓνϟͷ௨Γ ఆ௨Γͷܭࢉ͕͞Ε·ͨ͠ ܭࢉ݁Ռ͕Ͱ͋Δ͜ͱΛ֬ೝ
Slide 37
Slide 37 text
ײ
Slide 38
Slide 38 text
ࠓճͬͯΈͯ… ࠓճɺͷΑ͏ͳԋࢉࢠͱͭͷ୯७ͳܭࢉࣜͰ͕ͨ͠ɺ ԼهͷΑ͏ͳෳߦͷܭࢉʹରԠ͠Α͏ͱ͢Δͱ ͏গ͍͠ํΛ͢Δඞཁ͕͋Γͦ͏Ͱ͢ ͏গͯ͠͠࡞Γ͔ͨͬͨͰ͕͢ɺ·ͨ࣍ͷػձʹ ɹɹɹɹɹɹɹɹɹɹ ɹɹɹɹɹɹɹɹɹɹ FYෳߦͷܭࢉࣜΛಡΈࠐΉࡍͷྫ
Slide 39
Slide 39 text
·ͱΊ
Slide 40
Slide 40 text
RubyͬͯΠΠͰ͢ΑͶ✨ ࠓճ3VCZͷτϥϯΫʹՃ͞Εͨ ϕʔλ൛ͷύλʔϯϚονϯάΛ3VCZͷΠϯλϓϦλͷ࣮ ͱ͍͏έʔεΛྫʹ͍ͬͯ͡Έ·ͨ͠ ͬͺΓ3VCZͰίʔυΛॻ͘ͷָ͍ͬͯ͠Ͱ͢ΑͶ✨☺ 3VCZͷདྷϦϦʔε͕ࠓ͔Βָ͠ΈͰ͢ SCFOW͔ΒखܰʹམͱͤΔͷͰ ·ͩͷํ2.7Λࢼͯ͠Έ͍͔͕ͯͰ͠ΐ͏͔
Slide 41
Slide 41 text
ͱ͍͏Θ͚Ͱ
Slide 42
Slide 42 text
8FBSF)JSJOH 4503&4KQ Ұॹʹಇ͍ͯ͘ΕΔؒΛืू͍ͯ͠·͢