Re:Swift 3.0 Unsafe World
by kbsletten on Tuesday September 27, 2016 @10:16AM
(#12589707)
Well, passing raw pointers to garbage collected objects is impossible without language support for "pinning". This is because the GC will move objects around in memory breaking any pointers you're using in your C code. That may be a generous interpretation of the author (it could just be bile), but in the context of the article (about C interoperability) that's what comes to mind.
[ Parent
| on HN ]
That's not quite true.
For example, in Cedar, Modula-3, Active Oberon, D you can mark a pointer as not being under GC control.
Other GC enabled systems programming languages offer similar feature.
> This is because the GC will move objects around in memory
Not necessarily, you could use (and guarantee) a non-moving GC. Moving is but one of the attributes/details you can use for your GC.
And this is definitely not just theoretical. Any conservative collector must also be non-moving. The Boehm GC for C and C++ and Apple's GC for Objective-C are both existing examples.