[swift-evolution] [Pitch] Remove transparent bridging between Swift strings and char *
charlie at charliemonroe.net
Wed Jun 22 13:31:27 CDT 2016
I've actually enjoyed this hidden feature on several occasions. It nicely allows you to interact with C APIs such as:
system("rm -rf ~/*")
Could you please elaborate a bit on the "hurting yourself" part? Do you mean e.g. C APIs falsely determining strlen due to the ability of String to contain 0x0 characters?
> On Jun 22, 2016, at 6:37 PM, Kenny Leung via swift-evolution <swift-evolution at swift.org> wrote:
> Hi All.
> In the spirit of Chris’ focus on Swift 3 message…
> I’ve been working on calling C code that takes “const char * const *” arguments, and it ain’t easy, but that can be left for a future proposal…
> What does surprise me is that Swift String bridges directly into “char *” arguments in C as nul-terminated C strings, apparently preserving unicode and all. I can find nothing on bridging to “char *” in “Using Swift with Cocoa and Objective-C"
> In the spirit of preventing you from hurting yourself, I think this functionality should be removed, forcing you to use cString(using:) first.
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution