@kongtomorrow @pilky it’d make sense to me that the compiler would implicitly optionalize a non-optional type
-
-
- View other replies
-
@SteveStreza@kongtomorrow Still seems a little weird. As much as I dislike strong typing, my gut feeling is that should be an error -
@pilky@kongtomorrow a non-optional T fully satisfies the requirements of optional T. The compiler should infer that and autobox it up. - View other replies
-
@stevestreza@pilky updated gist to be more clear about what I think it must be doing.https://gist.github.com/kongtomorrow/8d1ac5161021451c794c … -
@kongtomorrow@SteveStreza@pilky Any reason why you use (Int?) instead of Int? in the definition of foo? Both work but still less () > ∞ -
@ozaed@stevestreza@pilky wanted to be clear that it wasn't the function itself that was optional, given that that's what we're focusing on -
@kongtomorrow@SteveStreza@pilky But you run into different semantics with additional (), see the Swift book about multiple return values -
@ozaed@stevestreza@pilky tuple containing a single A and A are identical in Swift. Try ((((((((A)))))))). - Show more
-
-
-
@kongtomorrow Maybe T is a subtype of T? ? -
@optshiftk@kongtomorrow Swift silently upconverts T into T? so that you can pass non-optionals into optional arguments. - View other replies
-
@airspeedswift@optshiftk can't very well reach inside of the closure to do it, though. Must allocate a wrapping closure. - View other replies
-
@kongtomorrow@airspeedswift Actually, the compiler might even be choosing some printlnHelper(_: Int?) based on the *call site*. - View other replies
-
@optshiftk@airspeedswift it'd have to do that _everywhere_ though if that was the case. It's not hard for caller to wrap in a closure… - View other replies
-
@optshiftk@airspeedswift …just more work than I'd expect to be happening implicitly in a lang that won't even coerce number types.
-
-
@kongtomorrow Type systems: how do they work? -
@kongtomorrow@pilky I think it's actually quite beautiful that this works. -
@kongtomorrow How is this incorrect behavior? It exhibits the same behavior as if ‘f’ was a pure optional. What am I missing?
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Ken Ferry
Spooky Streza
Martin Pilkington
Mugwump
Kyle S.
Airspeed Velocity
Tammo Freese
Ezekiel Pierson