> Agreed. Let me ask the question differently: what value does the > leading `.` provide to the user of the language?
I find the leading-dot syntax to be very useful; it's a pretty clear shorthand that I'm not referencing something at global scope. Here's a common example from our codebase: completion(.Failed(.wrap(error))) The completion function takes an enum value of type DataTransactionResult, of which .Failed is one case. The .Failed case takes an associated value of type DataTransactionError, which has a static function called wrap() that accepts an ErrorType and returns a DataTransactionError containing it. Although .Failed is being used here in the common enum shorthand style, being able to very quickly determine that wrap() is not a global function is helpful. Without the leading dot, some context disappears: completion(Failed(wrap(error))) Now, it's a lot harder to tell what I'm dealing with. What is 'Failed'? Is it a class with an initializer that we're passing the result of wrap(error) to? Or is it an enum case with an associated type? Further, what's wrap()? A function in the global scope? Sure looks like it! If we got rid of the shorthand altogether, we end up with something much more verbose: completion(DataTransactionResult.Failed(DataTransactionError.wrap(error))) Yes, it's more explicit, but I would not necessarily argue that it's easier to read.
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
