func serialization() -> String {
var serialized = ""
serialized += String(SerializedValue(turn: turn))
serialized += "n"
serialized += String(SerializedValue(board: board))
serialized += "n"
return serialized
}
@Serialization
func serialization() -> String {
turn
board
}
@_functionBuilder
enum Sample {
//
}
@Sample
func execute() -> Component
{
// DSL
}
init(@Sample body:()->Component) {
// DSL
}
1. buildExpression(_: Expression) -> Component
2. buildBlock(_: Component ...) -> Component
3. buildDo(_: Component ...) -> Component
buildEither(first: Component) -> Component
buildEither(second: Component) -> Component
buildFunction(_: Components...) -> Return
buildOptional(_: Component?) -> Component
static func buildBlock(
_ a: Component, _ b: Component) -> Component {
}
static func buildBlock(_ a: Int, _ b: String, _ c: Bool) -> Component {
}
static func buildBlock(_ components: Component...) -> Component {
}
static func buildBlock(_ a: Int, _: Void) -> Component {
}
static func buildExpression() -> Component {
}
static func buildExpression(_ expression: Expression) -> Component
{
}
static func buildExpression(_: Void) -> Component {
}
static func buildExpression(_: Never) -> Component {
}
static func buildExpression(_: Never) -> Component {
}
static func buildExpression<T>(_ expression: T) -> T {
return expression
}
Do
static func buildDo(_ component: Component) -> Component {
}
If
if … {
①
}
else {
②
}
BLOCK
2nd1st
if … {
①
}
else if {
②
}
else {
③
}
2nd1st
BLOCK
2nd1st
2nd1st
if … {
①
}
else if … {
②
}
else if … {
③
}
else {
④
}
BLOCK
2nd1st
2nd1st
if … {
①
}
else if … {
②
}
else if … {
③
}
else if … {
④
}
else {
⑤
BLOCK
1st 2nd 1st
2nd
1st 2nd
1st
2nd
BLOCK
1st 2nd 1st
2nd
1st 2nd
1st
2nd
1st 2nd
BLOCK
1st 2nd 1st
2nd
1st 2nd
1st
2nd
1st 2nd
1st 2nd
BLOCK
1st 2nd 1st
2nd
1st 2nd
1st
2nd
1st 2nd
1st 2nd 1st 2nd
BLOCK
1st 2n 1st
2nd
1st 2n
1st
2n
1st 2n
1st 2n 1st 2n
1st
2nd
BLOCK
1st 2n 1st
2nd
1st 2n
1st
2n
1st 2n
1st 2n 1st 2n
1st
2nd
2nd1st
BLOCK
1st 2n 1st
2nd
1st 2n
1st
2n
1st 2n
1st 2n 1st 2n
1st
2nd
2nd1st
1st 2n
if … {
①
}
else {
if … {
②
}
else {
③
}
}
BLOCK
2nd1st
2nd1st
BLOCK
Build Block
Build ExpressionBuild Expression
Build DoBuild Do
Build Function
Build If
Build Optional
Build Block
Build DoBuild Either
Build Block
_Function Builders in Swift #love_swift

_Function Builders in Swift #love_swift