> On Mar 11, 2017, at 12:57 AM, Jean-Daniel via swift-evolution
> <[email protected]> wrote:
>
> -1
>
> It would be inconsistent to allow it for deterministic literals (String) and
> not for non deterministic literal (int which can be either a Int, Uint,
> Float, …)
If I’m not mistaken, even with `bar = “baz”`, `String` is merely the default
inferred type. It could be anything that conforms to
`ExpressibleByStringLiteral`, right? In that regard, this is kinda just a way
to make a function implicitly generic:
func foo(bar = "baz") {…}
becomes:
func foo<T: ExpressibleByStringLiteral>(bar: T = "baz") {…}
Is there anything we can do with a variable, if all we know of it is that it
conforms to `ExpressibleByStringLiteral`? I can’t think of anything… If we had
a way to get back the literal string which the variable was initialized with,
we could initialize other values with that, but the protocol doesn’t require us
to store it. Come to think of it, is there even a way to store a literal value
in its “untyped” form? You can declare a variable to of type
`IntegerLiteralType`, but the type system then treats it as an `Int`.
So while it looks nice (to me, anyway) I’m not sure you could actually do
anything with it. Or am I looking at this wrong?
- Dave Sweeris_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution