Slide 1

Slide 1 text

Tomoki Ota ʲGoݴޠʳΫϩʔδϟ࣮ફฤ

Slide 2

Slide 2 text

Ϋϩʔδϟ࣮ફฤ GoͷΠςϨʔλ ΞδΣϯμ 2

Slide 3

Slide 3 text

Ϋϩʔδϟͱ͸ʁ

Slide 4

Slide 4 text

Ϋϩʔδϟͱ͸ʁ 4 •؀ڥΛΩϟϓνϟͰ͖Δແ໊ؔ਺

Slide 5

Slide 5 text

ϝϦοτ 5 • άϩʔόϧม਺Λ༻͍Δඞཁ͕ͳ͘ͳΔ • ؔ਺ͷείʔϓΛ੍ݶͰ͖Δ

Slide 6

Slide 6 text

Ϋϩʔδϟͷ৔߹ 6

Slide 7

Slide 7 text

ؔ਺ͷ৔߹ 7

Slide 8

Slide 8 text

Ϋϩʔδϟ࣮ફฤ

Slide 9

Slide 9 text

9 ࠨͷίʔυͷ ໰୊఺͸ʁ

Slide 10

Slide 10 text

10 ໰୊఺1 ॏ͍ॲཧcalcTrainingRepsͷݺͼग़͠෦෼͕ ෳ਺Օॴ͋ΔͷͰɺมߋ͕໘౗

Slide 11

Slide 11 text

11 ໰୊఺2 ॏ͍ॲཧΛෳ਺ճ࣮ߦ͠ͳ͚Ε͹ͳΒͳ͍ Մೳੑ͕͋Δɻ

Slide 12

Slide 12 text

12 ؔ਺ͰϦϑΝΫλ

Slide 13

Slide 13 text

13 ؔ਺ͰϦϑΝΫλ ͜Εͩͱ໰୊఺2͕ղܾ͍ͯ͠ͳ͍ɻ ͞ΒʹɺrepsΛ࢖༻͠ͳ͍ͱ͖΋ ॏ͍ॲཧΛݺͼͩ͞ΕΔͱ͍͏৽ͨͳ໰୊఺͕ ௥Ճ͞ΕΔɻ

Slide 14

Slide 14 text

14 ΫϩʔδϟͰϦϑΝΫλ ΫϩʔδϟΛ࢖͏͜ͱͰɺreps͕ඞཁͳ͚࣌ͩ ίʔυΛ࣮ߦ͢Δ

Slide 15

Slide 15 text

ߴ֊ؔ਺

Slide 16

Slide 16 text

ߴ֊ؔ਺ͱ͸ʁ 16 ؔ਺ΛҾ਺ʹͱͬͨΓɺؔ਺Λ໭Γ஋ͱͨ͠Γ͢Δؔ਺

Slide 17

Slide 17 text

ϝϦοτ 17 ϓϩάϥϜͷॊೈੑ ίʔυͷ؆ܿੑ ࠶ར༻ੑ ϝϯςφϯεੑ

Slide 18

Slide 18 text

Goʹ͓͚Δߴ֊ؔ਺ 18

Slide 19

Slide 19 text

ίʔϧόοΫ 19

Slide 20

Slide 20 text

ΧϦʔԽ

Slide 21

Slide 21 text

ΧϦʔԽͱ͸ʁ 21 f(a, b, c)Λf(a)(b)(c)ͷΑ͏ʹҾ਺Λ1ͭʹ͢Δ

Slide 22

Slide 22 text

22 ΧϦʔԽ͍ͯ͠ͳ͍ྫ ΧϦʔԽΛ࢖ͬͯϦϑΝΫλͨ͠ྫ

Slide 23

Slide 23 text

෦෼ద༻

Slide 24

Slide 24 text

෦෼ద༻ 24 ΧϦʔԽ͞Εͨؔ਺͸ɺ೚ҙͷҾ਺Λݻఆͨ͠ผͷؔ਺Λ࡞੒͢Δ͜ͱ͕Ͱ͖Δ

Slide 25

Slide 25 text

25 ෦෼ద༻

Slide 26

Slide 26 text

CPS

Slide 27

Slide 27 text

CPSͱ͸ʁ 27 continuation-passing styleɺܧଓ౉͠ελΠϧͱ͍͏ɻ ؔ਺ͷୈ1Ҿ਺ʹɺޙʹଓ͘ॲཧ(ܭଌ)Λ౉͢ϓϩάϥϛϯάελΠϧ C΍JavaͰ͸ɺޙʹଓ͘ॲཧΛηϛίϩϯͱվߦͷޙʹଓࣜ͘

Slide 28

Slide 28 text

CPSͷ৚݅ 28 •First-class Function(ୈҰڃؔ਺) •Tail-Call optimization(຤ඌݺͼग़͠࠷దԽ) GoͷίϯύΠϥ͸ରԠ͍ͯ͠ͳ͍

Slide 29

Slide 29 text

CPSͷ৚݅ 29

Slide 30

Slide 30 text

CPSͷྫ 30

Slide 31

Slide 31 text

CPSͷ৚݅ 31

Slide 32

Slide 32 text

࠶ؼͱ຤ඌ࠶ؼ 32

Slide 33

Slide 33 text

࠶ؼͱ຤ඌ࠶ؼ 33

Slide 34

Slide 34 text

࠶ؼͱ຤ඌ࠶ؼ 34

Slide 35

Slide 35 text

δΣωϨʔλ

Slide 36

Slide 36 text

δΣωϨʔλͱ͸ 36 ΠςϨʔλΛ؆୯ʹ࡞Δ͜ͱ͕Ͱ͖ΔɻΠςϨʔλΛฦؔ͢਺ δΣωϨʔλؔ਺ͱ΋͍͏ɻ ·ͨɺδΣωϨʔλؔ਺Ͱ࡞੒͞ΕͨΠςϨʔλͷ͜ͱΛ δΣωϨʔλͱݺͿ͜ͱ΋͋Δɻ

Slide 37

Slide 37 text

GoͷΠςϨʔλ

Slide 38

Slide 38 text

range over int

Slide 39

Slide 39 text

range over int 39 Go1.22Ҏ߱ Go1.22Ҏલ

Slide 40

Slide 40 text

range over func

Slide 41

Slide 41 text

range over func 41 GoͷΠςϨʔλͷσϑΝΫτελϯμʔυ

Slide 42

Slide 42 text

v1.23ҎલͷΠςϨʔλ 42 database/sql.Rows archive/tar.Reader.Next

Slide 43

Slide 43 text

range over func 43 ҎԼͷγάωνϟͷؔ਺ΛrangeͰ൓෮ॲཧͰ͖Δɻ

Slide 44

Slide 44 text

range over func 44

Slide 45

Slide 45 text

range over func 45 rangeͰyieldΛ࢖༻͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹͳͬͨɻ

Slide 46

Slide 46 text

GoͷΠςϨʔλ 46 • PushελΠϧ : 1ͭͣͭσʔλΛ౉͢ • PullελΠϧ : 1ͭͣͭσʔλΛड͚औΔ

Slide 47

Slide 47 text

func(func()bool) 47

Slide 48

Slide 48 text

48 func(func(V)bool)

Slide 49

Slide 49 text

func(func(K, V)bool) 49

Slide 50

Slide 50 text

iterύοέʔδ

Slide 51

Slide 51 text

iterύοέʔδ 51 https://github.com/golang/go/tree/go1.23.0/src/iter 1.23Ͱ௥Ճ͞Εͨ