|
|
|
|
|
by randomNumber7
147 days ago
|
|
I think Swift has great C interop but they made pointers too diffcult to use. Which of the following type do you have to use if your C API returns some pointer? UnsafeMutablePointer, UnsafePointer, UnsafeMutableBufferPointer, UnsafeBufferPointer, UnsafeMutableRawPointer, UnsafeRawPointer, UnsafeMutableRawBufferPointer, UnsafeRawBufferPointer ?? This is comical and the only reason to make it this clunky is because "unsafe is bad" and you don't want people to use it. |
|
- Mutable or not
- Typed or Raw
- Single object, or Buffer
Given one kind of pointer, you can convert to any other kind of pointer, but you are responsible for knowing if it’s safe to do.
The API is not super intuitive, but I can see how it makes it more clear what you are doing in your code.