[swift-evolution] : [Proposal] Change UnicodeScalar initializer to failable
Dmitri Gribenko
gribozavr at gmail.com
Wed Jul 20 00:32:16 CDT 2016
On Tue, Jul 19, 2016 at 10:14 AM, Xin Tong via swift-evolution
<swift-evolution at swift.org> wrote:
> Hi,
>
> I would like to propose changing unicodescalar initializer to failable.
>
> Currently, when you pass an invalid value to the UnicodeScalar initializer
> the swift stdlib crashes the program by calling _precondition. This is bad
> if you construct a unicode scalar from unknown input.
>
> As a result. I would like to propose to mark the initializer as failable and
> return nil in case of a failure.
+1, thank you for working on this improvement!
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the swift-evolution
mailing list