[swift-evolution] Dynamic Class/Struct Definition At Run Time

Xiaodi Wu xiaodi.wu at gmail.com
Tue Oct 11 16:04:28 CDT 2016


Reflection is likely to be tackled in Swift 5, no? So realistically, this
could be on track for Swift 6 or 7. Let's postpone discussion until then.


On Tue, Oct 11, 2016 at 15:59 David Sweeris via swift-evolution <
swift-evolution at swift.org> wrote:

>
> On Oct 11, 2016, at 12:40, Anton Zhilin via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> Hello Ted,
> First of all, this topic belongs to reflection, which is specifically
> stated to be out of scope of Swift 4 Phase 1. So all considerations are
> purely theoretical for now.
> That said, I also thought about this problem. The best I could imagine is
> something along the following lines:
>
> var builder = StructBuilder(name: "Person")
> builder.addProperty(name: "name", type: String.self)
> builder.addProperty(name: "age", type: Int.self)
> builder.addComputedProperty(name: "description", getter: { (this: Any) -> String in ... })
> builder.addComformance(CustomStringConvertible.self)let type: Any.Type = builder.build()
>
> Obviously, to interact with such dynamic types and their objects, we need
> the whole working reflection system that we don’t have right now.
>
> I *think* that's only true for non-generic code, and types that aren't
> subclasses... I think...
>
> Anyway, I'm starting to wonder if some code I'm trying to write might be
> impossible without either this feature, or some/all of the stuff from the
> generics manifesto. So put me down as, in principle, a strong +1 (pending
> details of the proposal when it actually gets written for Swift 10).
>
> - Dave Sweeris
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161011/fcaeb5c7/attachment.html>


More information about the swift-evolution mailing list