On 4/17/2014 12:41 PM, Steven Schveighoffer wrote:
On Thu, 17 Apr 2014 14:47:00 -0400, Walter Bright <newshou...@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?

Can you call malloc() ?

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.

You never used malloc? for anything? or stack allocated anything? or had any pointers to anything that weren't ref counted?

How did that work for printf?


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.

So there *are* regular pointers.

There is no need to know, you just use them like normal
pointers, and the compiler inserts the retain/release calls for you.

I know that with ARC the compiler inserts the code for you. That doesn't make it costless.


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.

I know it's done automatically. But you might be horrified at what the generated code looks like.

Reply via email to