I want you to deep dive into Swift Literals? - Literals in Swift - Object of Literals - Architecture of Type from Literals - Conclusion Agenda High-Level Low-Level
%a = some value 1 ⭕ %b = some value 2 ⭕ %a = some value 3 ❌ Value - Object is assigned to value at each line - Assigning to one value is allowed only once
42 %5 = struct $Int (%4 : $Builtin.Int64) store %5 to %3 : $*Int Literal Object (%4) is passed to Int Initializer Let’s read SIL let assigningLiteral: Int = 42
42 %5 = struct $Int (%4 : $Builtin.Int64) store %5 to %3 : $*Int Literal Object (%4) is passed to Int Initializer Let’s read SIL let assigningLiteral: Int = 42
42 %5 = struct $Int (%4 : $Builtin.Int64) store %5 to %3 : $*Int The generated Int Object is assigned to allocated place let assigningLiteral: Int = 42 Let’s read SIL
value: Builtin.IntLiteral) } init(:Builtin.IntLiteral) is called on assigning Literal by = - Type which conforming with this protocol is convertible by Literal Object
= struct $Int (%4 : $Builtin.Int64) What is _ExpressibleByBuiltin***Literal protocol? - Type which conforming with this protocol is convertible by Literal Object
IntegerLiteralType) {} } let value: OriginalIntegerType = 10 1. Set typealias to IntegerLiteralType the type should be converted from Integer Literal ExpressibleBy***Literal How to make Original Type convertible from Literal?
IntegerLiteralType) {} } let value: OriginalIntegerType = 10 2. Implement Initializer which receives IntegerLiteralType value ExpressibleBy***Literal How to make Original Type convertible from Literal?
IntegerLiteralType) {} } let value: OriginalIntegerType = 10 You can initialize your type by Literal! ExpressibleBy***Literal How to make Original Type convertible from Literal?
IntegerLiteralType) {} } let value: OriginalIntegerType = 10 ExpressibleBy***Literal How to make Original Type convertible from Literal? 1. Set typealias to IntegerLiteralType the type should be converted from Integer Literal
== …) Architecture of Type from Literals Back-End Function ift Type: ExpressibleBy*** ype: _ExpressibleByBuiltin*** eral Object ( = Builtin.***) Swift Ty Swift Type: Literal O