Slide 1

Slide 1 text

Θ͍Θ͍Operator Θ͍Θ͍swiftc #5 @giginet

Slide 2

Slide 2 text

iOSDCͷLT !

Slide 3

Slide 3 text

• Protocol Extension͔ΒᤈࢠΛੜ΍͢Έ͍ͨͳωλΛ΍ͬͨ

Slide 4

Slide 4 text

͜Εpostfix operatorͰͰ͖ͳ͍ͷʁ !

Slide 5

Slide 5 text

import Foundation import Peafowl postfix operator ᤈ extension Int { postfix static func ᤈ(lhs: Int) -> Tile { return Tile(.character(lhs))! } } 1ᤈ

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

ແཧͦ͏

Slide 8

Slide 8 text

ύʔαʔΛಡΉ • https://github.com/apple/swift/blob/master/include/swift/AST/ Identifier.h#L94

Slide 9

Slide 9 text

/// isOperatorStartCodePoint - Return true if the specified code point is a /// valid start of an operator. static bool isOperatorStartCodePoint(uint32_t C) { // ASCII operator chars. static const char OpChars[] = "/=-+*%<>!&|^~.?"; if (C < 0x80) return memchr(OpChars, C, sizeof(OpChars) - 1) != 0; // Unicode math, symbol, arrow, dingbat, and line/box drawing chars. return (C >= 0x00A1 && C <= 0x00A7) || C == 0x00A9 || C == 0x00AB || C == 0x00AC || C == 0x00AE || C == 0x00B0 || C == 0x00B1 || C == 0x00B6 || C == 0x00BB || C == 0x00BF || C == 0x00D7 || C == 0x00F7 || C == 0x2016 || C == 0x2017 || (C >= 0x2020 && C <= 0x2027) || (C >= 0x2030 && C <= 0x203E) || (C >= 0x2041 && C <= 0x2053) || (C >= 0x2055 && C <= 0x205E) || (C >= 0x2190 && C <= 0x23FF) || (C >= 0x2500 && C <= 0x2775) || (C >= 0x2794 && C <= 0x2BFF) || (C >= 0x2E00 && C <= 0x2E7F) || (C >= 0x3001 && C <= 0x3003) || (C >= 0x3008 && C <= 0x3030); }

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

·ͱΊ • operatorͰ࢖͑Δจࣈίʔυ͸ܾ·ͬͯΔ • ϙϯυ͸operatorʹͰ͖Δ͕ɺϢʔϩ͸operatorʹͰ͖ͳ͍ • ଞʹ͋Δ͔΋

Slide 12

Slide 12 text

ΦϚέ • ࣮͸੃ṛ͸શͯUnicodeʹׂΓ౰ͯΒΕ͍ͯΔ • ͜Ε͸ΦϖϨʔλʔʹͰ͖ͳ͍ʁ

Slide 13

Slide 13 text

ແཧͩͬͨ

Slide 14

Slide 14 text

ΦϚέ2 • ੃ṛΛ൑ఆ͢ΔCharacterSetͰ͢ import Foundation public let MahjongTileCharacterSet = { () -> CharacterSet in let start = Character("").unicodeScalars.first! let end = Character("").unicodeScalars.first! let range: ClosedRange = start...end return CharacterSet(charactersIn: range) }()