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

Context Receiversに思いを馳せる / Context Receivers

uzzu
October 05, 2022

Context Receiversに思いを馳せる / Context Receivers

DroidKaigi2022 Dialogs - 2022/10/05 14:20-14:45
https://droidkaigi.jp/2022/timetable/363729

uzzu

October 05, 2022
Tweet

More Decks by uzzu

Other Decks in Technology

Transcript

  1. Cluster, Inc. All Rights Reserved. 3 ࣗݾ঺հ @uzzu Cluster, Inc.

    ιϑτ΢ΣΞΤϯδχΞ झຯ: VR, ࡶଟͳٕज़ݕূ, ಡॻ, DTM, ֨ήʔ, εϓϥ
  2. Cluster, Inc. All Rights Reserved. 5 ΞδΣϯμ ɾContext Receivers͕དྷΔ·Ͱͷ͓͞Β͍ ɾContext

    Receiversͱ͸ɺ࢖༻ྫ ɾContext Receiversͷ՝୊ɺࢥ͍ ɾ·ͱΊ
  3. Cluster, Inc. All Rights Reserved. 7 Compile-time Extension Interfaces https://github.com/Kotlin/KEEP/pull/87

    2017/10ࠒ ɾ࠷ॳظ͸ʮType Classesʯͱ͍͏λΠτϧͰproposal͕ॻ͔Ε͍ͯͨ ɾʮ͍ͭʹKotlinʹ΋ܕΫϥε͕དྷΔ…?!ʯͱ͍͏ࣄͰք۾͸੝Γ্͕Δ
  4. Cluster, Inc. All Rights Reserved. 9 Compile-time Extension Interfaces https://github.com/Kotlin/KEEP/pull/87

    ɾcompanion objectͱͷ໾ׂͷॏෳ ɾJVMͱͷ૬ޓӡ༻ ɾෳ਺ͷϨγʔόʹର͢Δ֦ுߏจ͕ඞཁ ɾimplicit parameterͷ೉͠͞ ɾetc…
  5. Cluster, Inc. All Rights Reserved. 10 Multiple receivers on extension

    functions/properties https://youtrack.jetbrains.com/issue/KT-10468 https://youtrack.jetbrains.com/issue/KT-42435
  6. Cluster, Inc. All Rights Reserved. 11 ͦͯ͠Context Receivers΁ https://github.com/Kotlin/KEEP/issues/259 https://github.com/Kotlin/KEEP/blob/master/proposals/context-

    receivers.md ឯ༨ۂંʹ͍ͭͯ΋Proposalʹॻ͔Ε͍ͯΔ (Alternative approaches and design tradeoffs) 1.6.20-M1 ʹͯPrototypeͱͯ͠ϦϦʔε https://blog.jetbrains.com/kotlin/2022/02/kotlin-1-6-20-m1- released/ freeCompilerArgs = listOf("-Xcontext-receivers")
  7. Cluster, Inc. All Rights Reserved. 19 ɾContext Functionͷείʔϓ֊૚ͷਂ͞(ݕ౼த) ɾReflectionະରԠ(Prototypeஈ֊Ͱ͸΍Βͳͦ͏ͳؾ͕) ɾΤοδέʔε΁ͷରԠ

    (Kotlin 1.8.0ͰҰ෦मਖ਼ࡁ) ɾSyntax Highlighting(Τϥʔ͸ు͘ͷͰے೑Ͱ) ɾetc… Context Receiversͷ՝୊(Future Work)
  8. Cluster, Inc. All Rights Reserved. 20 (ϓϩτλΠϓஈ֊Ͱͱ΍͔͍͘͏΂͖ Ͱ͸ͳ͍ͷ͸ঝ஌Ͱ) ɾهड़ͷબ୒ࢶ͕ଟͯ͋͘Μ·Γࠓ·ͰͷKotlinΒ͘͠ͳ͍Α͏ͳؾ͕͢Δͷ͕ ɹݸਓతʹ͸ٯʹ໘ന͍

    ɾCompile-time extensionํ໘Ͱ্͕ͬͨ՝୊͔ΒݟΔʹՄೳͳهड़͸ ɹ͜Ε͔ΒߜΒΕ͍ͯͬͯཉ͍͠ͳʔͱࢥ͍ͬͯΔ 
 ɹ(ཞ༻͕ාͯ͘ਂ͘͸৮Εͳ͍ਓʑ͕͍ͦ͏ͳͷ͸΋͍ͬͨͳ͍ɺͱ͍͏ҙຯͰ) ɾݱঢ়Ͱ΋ᙱ͍ͱ͜Ζʹख͕ಧ͘ͷͰݸਓతʹ͸ॿ͔Δ Context Receivers΁ͷࢥ͍
  9. Cluster, Inc. All Rights Reserved. 21 Context Receivers΁ͷࢥ͍ ɾͦ΋ͦ΋ͳͥ ”Context”

    ʹͳͬͨͷ͔…ʁ ɹ=> Multiple receiversͷϓϩτλΠϓͷஈ֊Ͱ ɹɹύϥϝʔλΛஔ͖׵͑ΔͨΊʹ͋ΔΘ͚Ͱ͸ͳ͘ ɹɹؔ਺ݺͼग़͠ͷͨΊͷίϯςΩετΛ௥Ճ͢Δҝͷ ɹɹઃܭ͕ඞཁͩͱؾ͍ͮͨҝ ɹɹ=> ύϥϝʔλͷ୅ΘΓʹ࢖༻͢Δ৔߹ʹ͸ ɹɹɹهड़͕৑௕ʹͳΔΑ͏׶͍͑ͯͯ͠Δ ɹɹɹ=> ཞ༻͞Εͳ͍Α͏ʹ https://youtrack.jetbrains.com/issue/KT-10468/Multiple-receivers-on-extension-functionsproperties#focus=Comments-27-4608759.0-0
  10. Cluster, Inc. All Rights Reserved. 22 Context Receivers΁ͷࢥ͍ ɾͦ΋ͦ΋ͳͥ ”Context”

    ʹͳͬͨͷ͔…ʁ ɹ=> Multiple receiversͷϓϩτλΠϓͷஈ֊Ͱ ɹɹύϥϝʔλΛஔ͖׵͑ΔͨΊʹ͋ΔΘ͚Ͱ͸ͳ͘ ɹɹؔ਺ݺͼग़͠ͷͨΊͷίϯςΩετΛ௥Ճ͢Δҝͷ ɹɹઃܭ͕ඞཁͩͱؾ͍ͮͨҝ ɹɹ=> ύϥϝʔλͷ୅ΘΓʹ࢖༻͢Δ৔߹ʹ͸ ɹɹɹهड़͕৑௕ʹͳΔΑ͏׶͍͑ͯͯ͠Δ ɹɹɹ=> ཞ༻͞Εͳ͍Α͏ʹ https://youtrack.jetbrains.com/issue/KT-10468/Multiple-receivers-on-extension-functionsproperties#focus=Comments-27-4608759.0-0 ͻΐͬͱͯ͠ਅ໘໨ʹimplicit parameterʹcode generationͳΓͰ ͪΌΜͱରԠͰ͖ΔΑ͏ʹɺ༨നͱͯ͠࢒͍ͯ͠ΔͷͩΖ͏͔…ʁ ؾʹͳΔ…ͦΘͦΘ…ৄ͍͠ਓڭ͍͑ͯͩ͘͞
  11. Cluster, Inc. All Rights Reserved. 23 ·ͱΊ ɾContext Receivers͸ܕΫϥεͷProposal͔Β 


    ɹෳ਺ͷϨγʔόʹର͢Δ֦ுߏจ͕ඞཁͱ͍͏ 
 ɹྲྀΕͰ࡞ΒΕͨ ɾKotlinʹͯ͠͸௝ࣗ͘͠༝౓ͷߴ͍Proposal ɾָ͍͠ͷ͸ࠓ͚͔ͩ΋…ʁ 
 ɹProposalΛಡΜͰָ͘͠ɹ ʂ