3 ms·
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
by kbsletten 10y ago
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.
- pjmlp 10y agoThat'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.
- masklinn 10y ago> 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.
- mikeash 10y agoAnd 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.
- masklinn 10y agoIIRC Go's GC is also non-moving for now (or has that changed in a recent version? I believe it was still non-moving around 1.5)