Post

Replies

Boosts

Views

Activity

Reply to Can a function with parameter packs return a non-generic value for each parameter?
It should be possible, but at present the compiler only allows implicit repeatable non-generic types, like (repeat String). Consider the following: func mirrorString<each M>(_ input: repeat each M) -> String { let result = (repeat String(describing: each input)) return String(describing: result) } The variable result has an implicit type. Option click the variable and see, let result: (repeat String). However it is not possible to explicitly declare (repeat String) as a variable type or a return type. I believe this to be a bug.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’23
Reply to Can a function with parameter packs return a non-generic value for each parameter?
It should be possible, but at present the compiler only allows implicit repeatable non-generic types, like (repeat String). Consider the following: func mirrorString<each M>(_ input: repeat each M) -> String { let result = (repeat String(describing: each input)) return String(describing: result) } The variable result has an implicit type. Option click the variable and see, let result: (repeat String). However it is not possible to explicitly declare (repeat String) as a variable type or a return type. I believe this to be a bug.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to Error: "Generic types with parameter packs are experimental"
In the Package.swift file when declaring the target, include swiftSettings: [.enableExperimentalFeature("VariadicGenerics")].
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to Error: "Generic types with parameter packs are experimental"
What is the correct means to apply -enable-experimental-feature VariadicGenerics to a Swift package? The flag seems to work when set in Swift Compiler - Custom Flags>Other Swift Flags in Build Settings of an iOS app.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to Error: "Generic types with parameter packs are experimental"
Does, -enable-experimental-feature VariadicGenerics apply?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’23