Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-4929] Support non-inout homogeneous tuple argument conversion to UnsafePointer<Element> #47506

Closed
atrick opened this issue May 18, 2017 · 3 comments
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@atrick
Copy link
Member

atrick commented May 18, 2017

Previous ID SR-4929
Radar None
Original Reporter @atrick
Type New Feature
Status Closed
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels New Feature, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 7808dc535688a7e3712964e3bfcd10a8

duplicates:

  • SR-11147 Add withUnsafeBufferPointer<T: HomogeneousAggregate, Result>

relates to:

  • SR-3590 Implicitly convert &Tuple to UnsafePointer<Tuple.Element>
  • SR-4649 Don't require & to pass value to UnsafeRawPointer
  • SR-5048 Tuples of homogenous contents should adopt a common protocol

Issue Description:

We should implement implicit conversion from homogeneous tuple arguments to UnsafePointer as follows:

func get(_ p: UnsafePointer<Int>, at index: Int) -> Int {
return p[index]
}

let tuple = (0, 1, 2)
_ = get(tuple, at: 0)

Otherwise, users need to create a mutable copy of the tuple before converting it to a pointer. This is primarily for users working around the absence of fast fixed size arrays in the language.

I'm filing this for completeness, because we want language consistency across all these bugs:

  • Support inout homogeneous tuple argument conversion to UnsafeMutablePointer<Element>.
    See [SR-3590] Implicitly convert &Tuple to UnsafePointer<Tuple.Element>.
    (source breaking in ridiculous cases)
  • [SR-1956] `withUnsafePointer` shouldn't take its argument as `inout`
    (additive... we don't need to ban the inout syntax)
  • Allow non-homgenous non-inout tuple arguments to be converted to UnsafeRawPointer.
    [SR-4649] "Don't require & to pass value to UnsafeRawPointer", is that it seeks to
    (additive)
@atrick
Copy link
Member Author

atrick commented May 18, 2017

This needs swift-evolution.

@atrick
Copy link
Member Author

atrick commented May 18, 2017

This is related to the swift-evolution pitch from smartgo (JIRA User) "[Pitch] Don't require & for UnsafeRawPointer"

@atrick
Copy link
Member Author

atrick commented Jul 16, 2019

This is a better proposal to fix the same problem:

SR-11147 Add withUnsafeBufferPointer(to: variable) where variable is any homogenous aggregate

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal labels May 18, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

No branches or pull requests

2 participants