[swift-evolution] [Pitch] Make `default` function parameter values more transparent
L. Mihalkovic
laurent.mihalkovic at gmail.com
Mon Jun 13 10:54:43 CDT 2016
I would understand the java notion of default implementation directly in the protocol for optional methods, but default values across any implementation ever dies not ring a bell as something I ever wished I had.
Regards
LM
(From mobile)
> On Jun 13, 2016, at 4:52 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>
> I'm not sure what enhancing defaults would look like, especially for protocols. Are you suggesting if there's a protocol like:
>
> protocol A {
> func requiredFunction(a, b, c) -> T
> }
>
> that you could then extend
>
> extension A {
> func requiredFunction(a, b = somedefault, c) -> T;
> }
>
> as a declaration without an implementation?
>
> -- E
>
>> On Jun 13, 2016, at 2:17 AM, Haravikk via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> As Charlie says the default value may not actually be public.
>>
>> There was a thread a while ago about allowing defaults to be defined in protocols, but I don’t think it ever got made into a proposal; this would be useful however in cases where you want a consistent, known default. Either that or you need the option of declaring a default value as public perhaps?
>>
>>> On 11 Jun 2016, at 14:35, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
>>>
>>> I just installed the current Swift 3 snapshot to play around with it (last from may crashed my Xcode all the time).
>>>
>>> I wanted to re-build a small project with (currently implemented) Swift 3 changes. Basically I had to look up on GitHub what the default value for deinitialize(count:) function was for UnsafeMutablePointer, just because Xcode and the docs can’t tell me that:
>>>
>>> /// De-initialize the `count` `Pointee`s starting at `self`, returning
>>> /// their memory to an uninitialized state.
>>> ///
>>> /// - Precondition: The `Pointee`s at `self..<self + count` are
>>> /// initialized.
>>> ///
>>> /// - Postcondition: The memory is uninitialized.
>>> public func deinitialize(count: Int = default)
>>> To cut it short:
>>>
>>> Could we make default function parameter values more transparent in Swift 3?
>>> Why are default parameter values translated to default rather than the actual value?
>>> Can we make this independent from docs?
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160613/87741393/attachment.html>
More information about the swift-evolution
mailing list