For every type T
in Swift, there is an associated metatype T.Type
.
Let's try to write a generic function like staticSizeof
. We will only consider its declaration; implementation is trivial and unimportant here.
Out first try would be:
package name.anton3.vkapi.generator.json | |
import com.fasterxml.jackson.annotation.JsonUnwrapped | |
import com.fasterxml.jackson.core.JsonParser | |
import com.fasterxml.jackson.databind.* | |
import com.fasterxml.jackson.databind.deser.ContextualDeserializer | |
import com.fasterxml.jackson.databind.deser.ResolvableDeserializer | |
import com.fasterxml.jackson.databind.deser.std.StdDeserializer | |
import com.fasterxml.jackson.databind.node.ObjectNode | |
import com.fasterxml.jackson.databind.node.TreeTraversingParser |
package name.anton3.layout | |
import java.util.* | |
import kotlin.collections.ArrayList | |
import kotlin.math.abs | |
class Dummy | |
fun readResource(name: String): String { | |
return Dummy::class.java.classLoader.getResource(name)!!.readText() |
This paper provides an alternative abbreviated lambda expression syntax, as well as an alternative syntax for transparent functions, compared to [@P0573R2].
[@P0573R2] introduces a notion of transparent functions, which aim to behave as close as possible to as if their body was directly inserted into the caller (except that their arguments are only computed a single time).
task<void> foo() { | |
co_return uninlineable_mess(); | |
} |
Add mixins, which contain both protocol requirements and stored properties. Mixins will subsume abstract class functionality and allow similar functionality on structs. They will also allow for safe multiple inheritance, defining standard "bricks" carrying interface, implementation and state, which can be reused in multiple types.
Typed throws
annotation specifies that a function can only throw errors of a certain type:
// Feature 1: @mixin extension | |
struct Pizza { | |
var containsCheese: Bool | |
init(cheese: Bool) { ... } | |
func prepare() { print(self) } | |
} | |
struct Margherita { | |
var pizza: Pizza | |
init() { pizza = Pizza(cheese: true) } |