Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduce Sub::Meta

Introduce Sub::Meta

918b601dbd1297d58105508fb880b598?s=128

Kenta Kobayashi

May 21, 2021
Tweet

Transcript

  1. Introduce Sub::Meta kobaken a.k.a @kfly8 Perlͷ։ൃମݧΛྑ͍͖ͯ͘͠💪

  2. ࣗݾ঺հ • kobaken a.k.a @kfly8 • ϞόΠϧϑΝΫτϦʔ • ΤϯδχΞ૊৫։ൃ੹೚ऀ •

    Ωʔϫʔυ: ODHDɺίʔνϯάɺ 1on1ɺDevOpsɺJobDescription • Japan Perl Association ཧࣄ • ࠷ۙɺ່̑ࡀʹUNOͰෛ͚Δ
  3. Perlͷ։ൃମݧΛྑ͍ͨ͘͠💪

  4. ։ൃମݧʹ͔ܽͤͳ͍ • ڧྗͳΤϥʔνΣοΫ • ิ׬ • ϑΥʔϚολ • ύϑΥʔϚϯε޲্ •

    ͳͲ
  5. ৘ใ ߏจɾ஋ɾܕ औಘ ར༻

  6. ৘ใ ߏจɾ஋ɾܕ औಘ ར༻ PPI Compiler::Lexer PPR

  7. ৘ใ ߏจɾ஋ɾܕ औಘ ར༻ Perl::Critic Perl::Lint Perl::MinimumV ersion Perl::LanguageS erver

    Spellunker::Pe rl
  8. ৘ใ ߏจɾ஋ɾܕ औಘ ར༻ RBS steep Sorbet RBI TypeProf ࢀߟɿhttps://techlife.cookpad.com/entry/2020/12/09/120454

  9. ৘ใ ߏจɾ஋ɾܕ औಘ ར༻ Sub::Meta

  10. ৘ใ ߏจɾ஋ɾܕ औಘ ར༻ Sub::Meta Types::TypedCodeRef Boundary Types::HasTypedMethods

  11. খ·ͱΊ • PerlͰ։ൃମݧΛྑ͍͖ͯ͘͠💪 • ͦͷͨΊʹɺϓϩάϥϜ͔Β৘ใ Λऔಘ͠ར༻͢ΔྲྀΕΛଊ͑Δ • Sub::Meta͸ɺ͜ͷྲྀΕͰ͍͏ਅ ΜதͷཱͪҐஔ •

    ؔ਺ͷϝλ৘ใΛར༻͠΍͘͢ ΔͨΊͷΦϒδΣΫτ܅
  12. PerlͰؔ਺ͷϝλ৘ใΛ ѻ͏ͱ͖ͷࠞཚ ಛʹҾ਺ɺฦΓ஋

  13. None
  14. ؔ਺addͷϝλ৘ใ ؔ਺໊͸ʁ add ύοέʔδ͸ʁ Foo Կߦ໨͔Βఆٛ͞Ε͍ͯΔʁ 3ߦ໨

  15. use Sub::Identify; sub_name(\&add) # => add stash_name(\&add) # => Foo

    my ($file, $line) = get_code_location(\&add)
  16. my $meta = Sub::Meta->new( sub => \&add ); $meta->subname #

    => add $meta->stashname # => Foo $meta->line # => 3
  17. Ͱ͸ɺҾ਺͸ʁ

  18. None
  19. None
  20. None
  21. None
  22. ୔ࢁ͋ΔPerlͷ όϦσʔγϣϯϞδϡʔϧୡ

  23. None
  24. None
  25. None
  26. Ҿ਺όϦσʔγϣϯ܅͝ͱʹ ϝλ৘ใͷऔΓѻ͏ͷ໘౗

  27. ৘ใ ؔ਺ͷϝλ Sub::Meta Data::Validator Smart::Args Type::Params Function::Parameters Sub::WrapInType …

  28. DEMO

  29. ฦΓ஋όϦσʔγϣϯ܅΋ ಉ༷ͷΞϓϩʔνͰղܾ

  30. ৘ใ ؔ਺ͷϝλ Sub::Meta Return::Type Function::Return Sub::WrapInType …

  31. ·ͱΊ • Perlͷ։ൃମݧΛྑ͍͖ͯ͘͠ 💪 • Sub::Meta͸ɺؔ਺ͷҾ਺ɺฦ Γ஋΋ؚΊͨϝλ৘ใΛ Sub::Metaʹू໿͠ɺ౷Ұతͳ ΠϯλʔϑΣʔεͰؔ਺ͷϝλ ৘ใΛѻ͑ΔΑ͏ʹ͢Δ܅

  32. ࠓޙ͸ʁ • Sub::MetaͷܕදݱΛ҆ఆͤ͞ Δ(issue #42) • Boundary ( Interface࣮૷ )ʹؔ

    ਺໊͚ͩͰͳ͘ɺฦΓ஋ɺҾ਺ ͷܕ΋Ճຯ͢Δ #1 • Ruby3 steepͷΑ͏ͳ੩తͳ νΣοΧʔͷPoC