Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Implement call? #140

Open
Aurel300 opened this issue Jan 3, 2019 · 1 comment
Open

Implement call? #140

Aurel300 opened this issue Jan 3, 2019 · 1 comment

Comments

@Aurel300
Copy link

Aurel300 commented Jan 3, 2019

E.g.:

if let x: Int = (call? ext.foobar()) as! Int {
  // ...
}

Possible issue – as? is also used with if let in Swift, so the above might be confusing if let x: Int = (call? ext.foobar()) as? Int { ... – is the else branch taken when the calls fails or when the type cast fails?

@nvgrw
Copy link

nvgrw commented Jan 3, 2019

If we have Swift semantics with optionals this'd give you an error because you're trying to cast an optional type to a non-optional, optionally.

If foobar returns an int256, say, then after call you would expect to have an int256?. However Int is not an optional type, so even a forced cast would crash the compiler. There's no way for this to work. If you do as! Int? then obviously you would expect x to be of type Int?, which resolves the ambiguity here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants