[swift-evolution] [Pitch] Add the DefaultConstructible protocol to the standard library
Xiaodi Wu
xiaodi.wu at gmail.com
Mon Dec 26 11:23:55 CST 2016
There's also Bool(), which gives you false. But if you look into the docs,
it tells you explicitly not to use Bool(). So, just to hazard a
guess--implementation artifact? After all, one can't prefix init with an
underscore.
On Mon, Dec 26, 2016 at 12:14 Tim Vermeulen via swift-evolution <
swift-evolution at swift.org> wrote:
> I’ve never seen anyone use the empty init for it before, and if I ever
> will, I’ll probably discourage it. What is it for, anyways? Isn’t
> `Int.allZeros` enough?
>
>
>
> > On 26 Dec 2016, at 18:09, David Sweeris <davesweeris at mac.com> wrote:
>
> >
>
> >
>
> >> On Dec 26, 2016, at 09:01, Tim Vermeulen via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> >>
>
> >> Then why is Int() allowed, and why does that return 0?
>
> >
>
> > Predictability, I'd guess. The memory has to be initialized to
> *something*. And, IIRC, some architectures can 0 out memory faster than
> filling it with some other pattern.
>
> >
>
> > - Dave Sweeris
>
>
>
> _______________________________________________
>
> 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/20161226/02306f62/attachment.html>
More information about the swift-evolution
mailing list