http://llvm.org/bugs/show_bug.cgi?id=15997

            Bug ID: 15997
           Summary: Support __weak(ptr) in Objective-C for creating __weak
                    references
           Product: new-bugs
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

When working on iOS apps using Objective-C with ARC and blocks, it is often
necessary to create __weak pointers to objects that are used in the block. This
is done to avoid creating retain cycles. However, it becomes tedious to
interrupts the natural flow of the code. Would it be possible to support a new
language construct that would enable code in a block to inform the compiler
that the pointer being used is __weak, and let the compiler generate that
variable? Here's what I have in mind:

aBlock = ^{ [__weak(self) doSomething]; };

This would be translated by the compiler into something like:

__weak typeof(self) weakSelf = self;
aBlock = ^{ [weakSelf doSomething]; };

That would be a really slick way to avoid the strong/weak dance that our app
code is currently encumbered with.

Thanks for considering my suggestion!
Josh Smith

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to