[cfe-dev] objc++ enhancements for new c++ features
John McCall via cfe-dev
cfe-dev at lists.llvm.org
Wed Mar 28 15:06:21 PDT 2018
> On Mar 28, 2018, at 5:55 PM, James Gregurich <bayoubengalml at mac.com> wrote:
>
>
>
>> On Mar 28, 2018, at 4:29 PM, John McCall <rjmccall at apple.com <mailto:rjmccall at apple.com>> wrote:
>>
>> There is no existing concept of a move-only block. That is just not how blocks work.
>> Just add __block to the declaration of tmp1.
>
>
> one cannot use __block with lambda syntax. One would have to give up lambda syntax. lambda syntax is preferable to blocks syntax because the explicit captures make for more understandable and configurable code. its much easier for a reader of code to reason upon what is going on in code with no non-obvious implicit activity happening as often happens with blocks syntax. we've had serious bugs that caused production hassles because objc pointers got implicitly and cyclically retained in a block capture. lambda syntax eliminates such bugs.
>
> btw. I realize that "isn't how blocks work" currently... I'm inquiring about the potential of making it more friendly to the c++ way of doing things. Again, my purpose is to improve the experience of the c++ programmer doing cocoa development.
There is no feasible way to change blocks to a "move-only" system. It is not compatible with the language design, because the original identity of the block is immediately erased into a block pointer.
John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180328/88535144/attachment.html>
More information about the cfe-dev
mailing list