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

iosdcrc_operator

 iosdcrc_operator

Swiftは何故か郵便屋さんを採用している話です #iOSDCRC

Shigure Shimotori

October 13, 2017
Tweet

More Decks by Shigure Shimotori

Other Decks in Programming

Transcript

  1. iOSDC 2017 Reject Conference day1
    ༣ศ԰͞Μͷԋࢉࢠ
    @S_Shimotori

    View full-size slide

  2. ͩΕ
    • @S_Shimotori / @S_Shimotori_pub
    • ͭΒֶ͍ੜ
    • iOSDCؔ܎3౓໨

    View full-size slide

  3. Custom Operators

    View full-size slide

  4. ԋࢉࢠΛࣗ࡞ʂͨͷ͍͠ʂ
    • xmartlabs/Eureka
    • ϑΥʔϜϏϧμʔ
    • +++ͰSectionΛ௥Ճ͢ΔͳͲ
    • thoughtbot/Runes
    • HaskellͰݟͨΑ͏ͳԋࢉࢠ͕࢖͑ΔΑ͏ʹͳΔ

    View full-size slide

  5. ͲΜͳԋࢉࢠ͕࡞ΕΔͷ͔ʁ

    View full-size slide

  6. ͜ΕΛݟ͓͚ͯ͹׬ᘳͰ͢ʂ

    View full-size slide

  7. ͳΜͱͳʙ͘๏ଇ͕͋Δʂ

    View full-size slide

  8. ͦͷ1: ࢖͑ͦ͏ͳASCIIจࣈ͸࢖͑Δ
    • ݟͨ͜ͱ͋Δ΋ͷͰ΄΅શͯ
    • ڍ͛ΒΕ͍ͯͳ͍จࣈΛݟΕ͹ೲಘ͔΋ʁ
    • ɹɹɹɹɹɹɹɹɹ΍ɹɹɹɹɹɹɹɹɹɹ΋ෆՄ
    • ɹ ͸dot operatorͰ࢖༻Մ
    l 4USJOH-JUFSBMͰ࢖༻
    b
    LFZXPSEͷઌ಄Ͱ࢖༻ JGͳͲ

    JNQMJDJUOBNFEQBSBNFUFSTͰ࢖༻ ͳͲ


    \^ UVQMFɼGVODUJPOͳͲͰ࢖༻
    <> BSSBZMJUFSBMͳͲͰ࢖༻
    ܕͷݺͼग़͠ɼ࿈ଓ͢ΔPQFSBUPSͷ෼ׂͳͲͰ࢖༻
    ۠੾Γͱͯ͠࢖༻
    ! BUUSJCVUFͰ࢖༻ !BWBJMBCMFͳͲ

    a Τεέʔϓ΍,FZ1BUI&YQSFTTJPOͰ࢖༻
    @ XJMEDBSEQBUUFSOͰ࢖༻
    A ༧໿ޠΛJEFOUJpFSʹ༻͍Δ࣌ʹ࢖༻

    View full-size slide

  9. ͦͷ2: identifierͰ࢖͑Δจࣈ͸جຊతʹ࢖͑ͳ͍
    • identifierͱoperator͸ผ෺
    • ઐ༻ͷΤϥʔ͕ଘࡏ͢Δ

    • ΋ͪΖΜΞϧϑΝϕοτ΍਺ࣈ͸࢖༻ෆՄ
    • ΋࢖༻ෆՄ
    ·Ί͖ͪ͠: ͜ͷΤϥʔจ۟͸ʮidentifier_when_expecting_operatorʯͷ໊Ͱ͔ͬ͠ΓSwiftʹ࣮૷͞Ε͍ͯ·͢
    https://github.com/apple/swift/blob/bf42def404abcc9239cf7856475da2c80b86cc70/include/swift/AST/DiagnosticsParse.def#L421

    View full-size slide


  10. U+3008-U+3020, U+3030
    ൣғμϒͬͯΔ͡ΌΜʁ
    U+3021-U+302Fɹ͕
    ·Ί͖ͪ͠: U+3021-U+3029͸ોभ߸ᛰͱ͍͏਺ࣈɼU+302A-U+302F͸੠఺ͱ͔੠ූͱ͔ݺ͹ΕΔ΋ͷɽཁ͸தࠃޠɽ
    ͱ͍͏͔U+3000-U+303Fࣗମ͕CJK Symbols and Punctuationͱ͍͏ΧςΰϦɽ

    View full-size slide

  11. ͦͷ3: ਺ֶه߸͕݁ߏ࢖͑Δ
    • ໼ҹͱ͔਺ֶه߸ͱ͔͕·Δͬͱ࢖͑Δ
    • mattt/Eulerͱ͍͏ϥΠϒϥϦ(?)͕͋Δ͘Β͍
    • ɹɹɹɹ͸࢖͑ͳ͍
    ΄͔ଟ਺
    ਖ਼֬ʹ͍͏ͱɼUnicodeͰʮArrowsʯʮMathematical OperatorsʯʮMiscellaneous TechnicalʯϒϩοΫͱݺ͹Ε͍ͯΔͱ͜Ζ͕
    ·Δ·Δ࢖༻Մೳʹͳ͍ͬͯΔ

    View full-size slide

  12. ͦͷ4 : ҙ֎ͱׅހ΍ϓϥΠϜ͕࢖͑ͪΌ͏
    • ASCIIจࣈͰμϝͰ΋ɼࣅͨจࣈ͕࢖͑Δ͜ͱ͕͋Δ



    • ٯʹ͍͏ͱׅހ΍ΫΥʔτͷྨ͸ม਺໊ʹ࢖͑ͳ͍

    View full-size slide

  13. ͦͷ5: ԋࢉࢠʹ࢖͑Δֆจࣈ΋͋Δ
    • ࢖͑Δͷ͸U+3030·ͰͷจࣈͷҰ෦ͱࢥͬͯOK

    ͸U+1F436ɼ͸U+1F42E
    • ֆจࣈͷଟ͘͸U+1F000Ҏ߱Ͱൣғ֎
    • U+3030Ҏલʹ͋Δֆจࣈ͸࢖͑Δ͔΋ʂ

    View full-size slide

  14. U+3030·ͰͷͲΕ͕ֆจࣈͳͷ͔
    • The Unicode Consortium͕ܾΊ͍ͯΔ
    • ΄ͱΜͲ͕࢖͑ΔͷͰɼҰཡΛݟͯωλΛ࿅Δͱྑ͠
    • ࢖͑ͳ͍ࢠ:
    • U+FE0FͱU+FE0E͕ԋࢉࢠ໊ͷ2จࣈ໨Ҏ߱Ͱ࢖͑Δ
    • ͭ·ΓֆจࣈελΠϧͱςΩετελΠϧ͸ผ෺ѻ͍
    Ұཡ
    http://unicode.org/Public/emoji/5.0/emoji-data.txt
    https://ja.wikipedia.org/wiki/Unicode%E3%81%AEEmoji%E3%81%AE%E4%B8%80%E8%A6%A7

    View full-size slide

  15. ͍͍ͩͨ͜Μͳײ͡ʂ

    View full-size slide

  16. ·ͱΊ
    • ࢖͑ͦ͏ͳASCIIจࣈ͸࢖͑Δ
    • identifierͰ࢖͑Δจࣈ͸جຊతʹ࢖͑ͳ͍
    • ਺ֶه߸͕݁ߏ࢖͑Δ
    • ҙ֎ͱׅހ΍ϓϥΠϜ͕࢖͑Δ
    • ಉ͡छྨͷจࣈ͕શ෦࢖͑ΔΘ͚Ͱ͸ͳ͍
    • ԋࢉࢠʹ࢖͑Δֆจࣈ΋͋Δ

    View full-size slide

  17. ࠷ޙʹ΋͏1ͭ

    View full-size slide

  18. ࣍ͷจࣈ͸ԋࢉࢠʹ࢖͑Δͷ͔ʁ
    ֆจࣈ͔Ͳ͏͔ ԋࢉࢠʹ࢖͑Δ͔

    ˟

    ˜
    š



    ֆจࣈ͔Ͳ͏͔ ԋࢉࢠʹ࢖͑Δ͔
    ὺ O :
    ˟ O :
    ⁴ O O
    ˜ : :
    š : :
    ℗ O O
    ä : O
    ℠ O O

    View full-size slide

  19. Θ͔ΒΜʂʂʂ

    View full-size slide