This issue is going to surface any time a method with a preposition and a single defaulted argument. I would say:
copy(with: )
Although I think we might have problematic results no matter what guidelines we use for
func doSomethingWith(completionHandler: (()->Void)? = nil)
since this can be called as
doSomethingWith() // doSomething()
Or
doSomethingWith {...} // doSomething {...}
Here are the problems with putting the preposition inside the parentheses:
1. You can't "distribute" the preposition over a number of arguments:
removeTracksHaving(mediaType: x, composer: y)
you end up with
removeTracks(havingMediaType: x, composer: y)
if you try to fix this with conjunctions
removeTracks(havingMediaType: x, andComposer: y, andLength: z)
and the first argument has a default, you end up with the wrong
implied semantics at the call site:
removeTracks(andComposer: y)
removeTracks(andLength: z)
2. You have to write:
move(toX: horizontal, y: vertical)
Here are the problems with putting the preposition outside the
parentheses:
1. If all arguments have defaults and the method is called with zero
arguments you have a dangling preposition as noted by Matthew. This
only happens
2. You have to write:
moveFrom(a, to: b)
IMO the consequences of putting prepositions inside the parens are worse
than the consequences of putting them outside.
···
on Sat Feb 06 2016, Matthew Judge <swift-evolution@swift.org> wrote:
On Feb 6, 2016, at 15:47, Jean-Daniel Dupas via swift-evolution <swift-evolution@swift.org> wrote:
Le 6 févr. 2016 à 21:15, Douglas Gregor via swift-evolution <swift-evolution@swift.org> a écrit :
Sent from my iPhone
On Feb 6, 2016, at 9:21 AM, Thorsten Seitz <tseitz42@icloud.com> wrote:
So the preposition should move into the argument label if the argument is optional?
copy(withZone: zone = nil)
Zone is redundant with type information.
copy(with:)?
copy(withZone:)?Wouldn’t it be possible to simply drop the copyWithZone: method that
is deprecated for some times now (To quote the doc: Zones are
ignored on iOS and 64-bit runtime on OS X. You should not use zones
in current development).-Thorsten
Am 06.02.2016 um 14:45 schrieb Matthew Judge via swift-evolution <swift-evolution@swift.org>:
Very first method
copyWith(zone: Zone = nil)
can be called as
copyWith()
I'm assuming this is still something we don't want right?
On Feb 6, 2016, at 02:16, Douglas Gregor via swift-evolution <swift-evolution@swift.org> wrote:
On Feb 5, 2016, at 1:32 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote:
Given all the awesome feedback I've gotten on this thread, I went back
to the drawing board and came up with something new; I think this one
works. The previously-stated goals still apply:[snip goals]
P.S. Doug is presently working on generating new importer results, based
on these guidelines, for your perusal. They should be ready soon.Here’s a link:
Feedback welcome!
- Doug
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
--
-Dave