[swift-users] Question about "lazy initialization" in CommandLine.arguments documentation

Kyle Murray kyle_murray at apple.com
Thu Jan 11 15:25:13 CST 2018


It looks like those comments originated as an implementation remark:

https://github.com/apple/swift/blame/ef863136f311b113dc9b41da0c65cb771dadf18b/stdlib/public/core/Process.swift#L17 <https://github.com/apple/swift/blame/ef863136f311b113dc9b41da0c65cb771dadf18b/stdlib/public/core/Process.swift#L17>


16
  public static let arguments: [String] = {
17
    // Use lazy initialization of static properties to safely initialize the
18
    // public 'arguments' property on first use.
19



Would you mind filing a bug on bugs.swift.org <http://bugs.swift.org/> for this? All of the properties on CommandLine could use some documentation attention.

-Kyle

> On Jan 11, 2018, at 1:55 AM, Martin R via swift-users <swift-users at swift.org> wrote:
> 
> The `CommandLine` documentation (https://developer.apple.com/documentation/swift/commandline) states about the `arguments` property:
> 
>    ... also use lazy initialization of static properties to safely initialize the swift arguments.
> 
> Apparently this originates from the markup comments in https://github.com/apple/swift/blob/master/stdlib/public/core/CommandLine.swift#L48:
> 
>    /// Access to the swift arguments, also use lazy initialization of static
>    /// properties to safely initialize the swift arguments.
>    public static var arguments: [String]
>      = (0..<Int(argc)).map { String(cString: _unsafeArgv[$0]!) }
> 
> 
> - Is this something the _user_ of `CommandLine` must know?
> - If yes, what does it tell me?
> - Or is it a remark about the _implementation_ (and should not be part of the public documentation)?
> 
> Regards, Martin
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20180111/d7e59035/attachment.html>


More information about the swift-users mailing list