[swift-users] Lazy expression is ambiguous?

Rick Mann rmann at latencyzero.com
Mon Sep 12 03:20:45 CDT 2016

> On Sep 12, 2016, at 00:53 , Quinn The Eskimo! via swift-users <swift-users at swift.org> wrote:
> On 12 Sep 2016, at 08:46, Rick Mann <rmann at latencyzero.com> wrote:
>> I had assumed lazy worked like static, which I understand uses dispatch_once under the hood.
> Correct.
> [I’m not sure if it actually /uses/ `dispatch_once` specifically, but it has the same semantics.]
>> Would that be a reasonable thing for lazy to do?
> It certainly would be nice.  I suspect that this would be hard to implement because the restrictions associated with `dispatch_once` are pretty tight.  OTOH, if you’d like to see it work this way it wouldn’t hurt to file an enhancement request.

Oh, right, because it seems to need a static or global variable for the flag. I've always wondered why that was the case. Seems like any flag would do (like a member variable), and if that results in a second dispatch because it's a second flag, that's okay.

In any case, thanks for all the clarification.

> Share and Enjoy
> --
> Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

Rick Mann
rmann at latencyzero.com

More information about the swift-users mailing list