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

哲学とSwiftの発表

Yuka Ezura
September 08, 2017

 哲学とSwiftの発表

社内勉強会での資料
## ギリシャ哲学とオブジェクト指向の話
* プラトン
* アリストテレス
## Swift
* lazyをletで宣言できるようにする話
* Swift のコンパイラをいじった話

Yuka Ezura

September 08, 2017
Tweet

More Decks by Yuka Ezura

Other Decks in Programming

Transcript

  1. ΠσΞք ײ֮ੈք class അ { property method }ɹ instance instance

    instance ීวͰӬԕͳ΋ͷ มԽ͠
 ੜ੒ɾফ໓͢Δ΋ͷ
  2. Swift Ͱͷ࣮૷ public class Lazy<T> { private let initializer: ()

    -> T private var _value: T! public var value: T { // TODO: mutex switch _value { case .none: _value = initializer() return _value case .some(let v): return v } } public init(initializer: @escaping () -> T) { self.initializer = initializer } } public func lazy<T>(initializer: @escaping () -> T) -> Lazy<T> { return Lazy(initializer: initializer) }
  3. extension Optional: CustomStringConvertible { public var description: String { switch

    self { case .none: return "" case .some(let wrapped): return "\(wrapped)" } } } "\("sss" as Optional)" ͖ͬ͞ؾ͍͚ͮͨͲɺ
 ͜ΕͰࡁΜͩ ͔ͤͬ͘΍͔ͬͨΒɺ
 ଞͷ΍Γํ΋࿩͠·͢ʂ
  4. "\(Normal() as Optional)" // -> "Optional(description)" "\(Force() as Optional)" //

    -> "description" // ------------------ struct Normal: CustomStringConvertible { var description: String { return "\(#function)" } } struct Force: CustomForceStringConvertible { var description: String { return "\(#function)" } } Goal
  5. "\(Normal() as Optional)" // -> "Optional(description)" "\(Force() as Optional)" //

    -> "description" // ------------------ struct Normal: CustomStringConvertible { var description: String { return "\(#function)" } } struct Force: CustomForceStringConvertible { var description: String { return "\(#function)" } } Goal զʑͷׯবͰ͖Δ෦෼
  6. "\(Normal() as Optional)" // -> "Optional(description)" "\(Force() as Optional)" //

    -> "description" // ------------------ struct Normal: CustomStringConvertible { var description: String { return "\(#function)" } } struct Force: CustomForceStringConvertible { var description: String { return "\(#function)" } } Goal զʑͷׯবͰ͖Δ෦෼ Λ௒͑ͳͯ͘͸͍͚ͳ͍
  7. "\(Normal() as Optional)" // -> "Optional(description)" "\(Force() as Optional)" //

    -> "description" // ------------------ struct Normal: CustomStringConvertible { var description: String { return "\(#function)" } } struct Force: CustomForceStringConvertible { var description: String { return "\(#function)" } } Goal զʑͷׯবͰ͖Δ෦෼ Λ௒͑ͳͯ͘͸͍͚ͳ͍
  8. खॱ • Swift ͷϓϩδΣΫτΛ࣋ͬͯདྷΔ • cmake ͱ ninja Λ࣋ͬͯདྷΔ •

    ࠷৽ͷ Xcode Λࢦఆ͢Δ • ม׵จࣈྻΛܾఆ͢Δͱ͜ΖΛม͑Δ
 (https://github.com/ezura/swift/commit/ 6e782f69265224a3b5321f9315039d36428dfcc7) • ίϯύΠϧ
  9. "\(Normal() as Optional)" // -> "Optional(description)" "\(Force() as Optional)" //

    -> "description" // ------------------ struct Normal: CustomStringConvertible { var description: String { return "\(#function)" } } struct Force: CustomForceStringConvertible { var description: String { return "\(#function)" } }