<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Support __weak(ptr) in Objective-C for creating __weak references"
   href="http://llvm.org/bugs/show_bug.cgi?id=15997">15997</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Support __weak(ptr) in Objective-C for creating __weak references
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>josh.smith@cynergy.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>