Question about "lazy initialization" in CommandLine.arguments documentation

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 swift/CommandLine.swift at main · apple/swift · GitHub

    /// 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

It looks like those comments originated as an implementation remark:

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 <Issues · apple/swift · GitHub; 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@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-users