[LLVMbugs] [Bug 15997] New: Support __weak(ptr) in Objective-C for creating __weak references

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 14 10:32:01 PDT 2013


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: unassignedbugs at nondot.org
          Reporter: josh.smith at cynergy.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130514/65f94cb7/attachment.html>


More information about the llvm-bugs mailing list