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

iosdcrc_operator

 iosdcrc_operator

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

Bf65cc9bdf26321a7579ddca7930cd10?s=128

Shigure Shimotori

October 13, 2017
Tweet

Transcript

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

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

  3. Custom Operators

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

    HaskellͰݟͨΑ͏ͳԋࢉࢠ͕࢖͑ΔΑ͏ʹͳΔ
  5. ͲΜͳԋࢉࢠ͕࡞ΕΔͷ͔ʁ

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

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

  8. ๏ଇͦͷ1

  9. ͦͷ1: ࢖͑ͦ͏ͳASCIIจࣈ͸࢖͑Δ • ݟͨ͜ͱ͋Δ΋ͷͰ΄΅શͯ • ڍ͛ΒΕ͍ͯͳ͍จࣈΛݟΕ͹ೲಘ͔΋ʁ • ɹɹɹɹɹɹɹɹɹ΍ɹɹɹɹɹɹɹɹɹɹ΋ෆՄ • ɹ

    ͸dot operatorͰ࢖༻Մ l 4USJOH-JUFSBMͰ࢖༻ b  LFZXPSEͷઌ಄Ͱ࢖༻ JGͳͲ  JNQMJDJUOBNFEQBSBNFUFSTͰ࢖༻ ͳͲ \^ UVQMFɼGVODUJPOͳͲͰ࢖༻ <> BSSBZMJUFSBMͳͲͰ࢖༻  ܕͷݺͼग़͠ɼ࿈ଓ͢ΔPQFSBUPSͷ෼ׂͳͲͰ࢖༻  ۠੾Γͱͯ͠࢖༻ ! BUUSJCVUFͰ࢖༻ !BWBJMBCMFͳͲ a Τεέʔϓ΍,FZ1BUI&YQSFTTJPOͰ࢖༻ @ XJMEDBSEQBUUFSOͰ࢖༻ A ༧໿ޠΛJEFOUJpFSʹ༻͍Δ࣌ʹ࢖༻
  10. ๏ଇͦͷ2

  11. ͦͷ2: identifierͰ࢖͑Δจࣈ͸جຊతʹ࢖͑ͳ͍ • identifierͱoperator͸ผ෺ • ઐ༻ͷΤϥʔ͕ଘࡏ͢Δ • • ΋ͪΖΜΞϧϑΝϕοτ΍਺ࣈ͸࢖༻ෆՄ •

    ΋࢖༻ෆՄ ·Ί͖ͪ͠: ͜ͷΤϥʔจ۟͸ʮidentifier_when_expecting_operatorʯͷ໊Ͱ͔ͬ͠ΓSwiftʹ࣮૷͞Ε͍ͯ·͢ https://github.com/apple/swift/blob/bf42def404abcc9239cf7856475da2c80b86cc70/include/swift/AST/DiagnosticsParse.def#L421
  12. ❌ 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ͱ͍͏ΧςΰϦɽ
  13. ๏ଇͦͷ3

  14. ͦͷ3: ਺ֶه߸͕݁ߏ࢖͑Δ • ໼ҹͱ͔਺ֶه߸ͱ͔͕·Δͬͱ࢖͑Δ • mattt/Eulerͱ͍͏ϥΠϒϥϦ(?)͕͋Δ͘Β͍ • ɹɹɹɹ͸࢖͑ͳ͍ ΄͔ଟ਺ ਖ਼֬ʹ͍͏ͱɼUnicodeͰʮArrowsʯʮMathematical

    OperatorsʯʮMiscellaneous TechnicalʯϒϩοΫͱݺ͹Ε͍ͯΔͱ͜Ζ͕ ·Δ·Δ࢖༻Մೳʹͳ͍ͬͯΔ
  15. ๏ଇͦͷ4

  16. ͦͷ4 : ҙ֎ͱׅހ΍ϓϥΠϜ͕࢖͑ͪΌ͏ • ASCIIจࣈͰμϝͰ΋ɼࣅͨจࣈ͕࢖͑Δ͜ͱ͕͋Δ • • • • ٯʹ͍͏ͱׅހ΍ΫΥʔτͷྨ͸ม਺໊ʹ࢖͑ͳ͍

  17. ๏ଇͦͷ5

  18. ͦͷ5: ԋࢉࢠʹ࢖͑Δֆจࣈ΋͋Δ • ࢖͑Δͷ͸U+3030·ͰͷจࣈͷҰ෦ͱࢥͬͯOK • ͸U+1F436ɼ͸U+1F42E • ֆจࣈͷଟ͘͸U+1F000Ҏ߱Ͱൣғ֎ • U+3030Ҏલʹ͋Δֆจࣈ͸࢖͑Δ͔΋ʂ

  19. 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
  20. ͍͍ͩͨ͜Μͳײ͡ʂ

  21. ·ͱΊ • ࢖͑ͦ͏ͳASCIIจࣈ͸࢖͑Δ • identifierͰ࢖͑Δจࣈ͸جຊతʹ࢖͑ͳ͍ • ਺ֶه߸͕݁ߏ࢖͑Δ • ҙ֎ͱׅހ΍ϓϥΠϜ͕࢖͑Δ •

    ಉ͡छྨͷจࣈ͕શ෦࢖͑ΔΘ͚Ͱ͸ͳ͍ • ԋࢉࢠʹ࢖͑Δֆจࣈ΋͋Δ
  22. ࠷ޙʹ΋͏1ͭ

  23. ࣍ͷจࣈ͸ԋࢉࢠʹ࢖͑Δͷ͔ʁ ֆจࣈ͔Ͳ͏͔ ԋࢉࢠʹ࢖͑Δ͔ ὺ ˟ ˜ š ℗ ™ ℠

    ֆจࣈ͔Ͳ͏͔ ԋࢉࢠʹ࢖͑Δ͔ ὺ O : ˟ O : ⁴ O O ˜ : : š : : ℗ O O ä : O ℠ O O
  24. Θ͔ΒΜʂʂʂ

  25. None