+1 for DSLs. I still give my vote to the concern that we might overcomplicate Swift for too little return.
Is there a way at all to achieve the same thing with existing language features but uglier syntax?
As a Swift user without knowledge of building compilers, I would expect SwiftUI to look like this:
VStack { builder in
builder.add(Text("Label 1"))
builder.add(Text("Label 2"))
if weAreInAGoodMood {
builder.add(Text("Label 3"))
}
}
... or a bit more streamlined:
VStack { builder in
builder.text("Label 1")
builder.text("Label 2")
if weAreInAGoodMood {
builder.text("Label 3")
}
}
Edit: And if I understand correctly: Of the SwiftIUI features we've seen, mainly (only) the stacks build views from multiple View expressions. Lists and possible future Grids aren't even touched by function builders. So an "ugly" syntax like pictured above wouldn't even be that pervasive in practical DSL scenarios ... (?)