Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

[SoM] SwiftRuntimeLibrary could be made friendlier with some implicit operators #128

Open
stephen-hawley opened this issue Aug 10, 2018 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@stephen-hawley
Copy link
Contributor

SwiftAnyObject which is used to represent the AnyObject type in swift has a static converter, but it might be nice to have an implicit operator for ISwiftObject.

SwiftImplicitlyUnwrappedOptional<T> could also benefit from this.
In swift, this is used to represent the type T!.

SwiftOptional<T> could also benefit from this from C# Optional<T>.

SwiftString could use benefit to C# string.

Would also be somewhat better with explicit operators.

@stephen-hawley stephen-hawley transferred this issue from another repository Oct 29, 2019
@chamons chamons added this to the Future milestone Nov 14, 2019
@stephen-hawley stephen-hawley added the enhancement New feature or request label Sep 22, 2020
@stephen-hawley
Copy link
Contributor Author

This was discussed on discord and this is the conclusion for now:
Sebastien: @steve.hawley @chamons yes, been there before. implicit op have bitten us a few times. WRT to NSString there's a cost to the operation that gets hidden from the developer (a string can be converted multiple times). Also we had, less common, issues (e.g. localization) with subclasses of NSString that could not convert back correctly (from string to NSString). So it's not always lossless - even if it seems to be

Steve: @sebastien that's a good point - but the good news is that Swift.String is a value type and can't be subclassed, so that doesn't apply. I'm with you on the tradeoff between easy-to-use and hidden cost.
I think maybe the right thing to do in this case is to no do the implicit operator and see if any asks for it and put this discussion into the issue for the future when it comes up again.

@rolfbjarne
Copy link
Member

I agree that we can wait and see, we can always add implicit operators later.

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

No branches or pull requests

3 participants