[swift-evolution] Unify the way properties and methods work to make key-value coding more natural

Tino Heth 2th at gmx.de
Thu Apr 13 01:57:09 CDT 2017


> While the \ syntax will only apply to key paths to begin with, we want to look into unifying all unapplied member references under that syntax.

Glad to hear that — I hope the core team will keep the courage to break syntax from time to time if the change improves the consistency of Swift.
But like anyone else, I prefer breaking changes to happen rarely, and I think other parts of the language should be taken into account as well.

KVC is nice, but I would really like to see some sort of namespace for querying and working with "meta-properties":
— function references
— properties
— MemoryLayout<T>
— functions (I'm thinking of stuff like introspection of parameters, and something like "apply" as a replacement for tuple splat)
— mirrors
— (most likely, I forgot some other possibilities)

There's no concrete vision for such a concept, but I'll just use ":" for illustration...
let appender: (Array<Int>, Int) -> Void = Array<Int>:methods:append
let someStaticFunction = MyType:classMethods:setGlobalInstance
let sizeProperty = Array:properties:size
let bytesNeeded = Double:memoryLayout.size
if theFunction:signature.parameters = [Int, Int] && theFunction:signature.returnType == T {
	return theFunction:callWith(myPairOfInt)
}
let parent = Self:superclass
for type in UIViewController:allKnownSubclasses {…

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170413/9e3cbadd/attachment.html>


More information about the swift-evolution mailing list