DIP60: @nogc attribute
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Thu Apr 17 12:41:45 PDT 2014
On Thu, 17 Apr 2014 14:47:00 -0400, Walter Bright
<newshound2 at digitalmars.com> wrote:
> On 4/17/2014 10:05 AM, Steven Schveighoffer wrote:
>>> Obj-C only uses ARC for a minority of the objects.
>> Really? Every Obj-C API I've seen uses Objective-C objects, which all
>> use RC.
>
> And what about all allocated items?
What do you mean?
>>> A UI is a good use case for ARC. A UI doesn't require high performance.
>> I've written video processing/players on iOS, they all use blocks and
>> reference
>> counting, including to do date/time processing per frame. All while
>> using RC
>> network buffers. And it works quite smoothly.
>
> And did you use ref counting for all allocations and all pointers?
Yes.
> There's no doubt that ref counting can be used successfully here and
> there, with a competent programmer knowing when he can just convert it
> to a raw pointer and use that.
The compiler treats pointers to NSObject-derived differently than pointers
to structs and raw bytes. There is no need to know, you just use them like
normal pointers, and the compiler inserts the retain/release calls for you.
But I did not use structs. I only used structs for network packet
overlays. I still created an object that contained the struct to enjoy the
benefits of the memory management system.
> And remember that if you have exceptions, then all the dec code needs to
> be in exception unwind handlers.
I haven't really used exceptions, but they automatically handle the
reference counting.
-Steve
More information about the Digitalmars-d
mailing list