Why no FloatingPointArithmeticType and DefaultInitializable protocols in stdlib?

Is there a reason why the standard library does not have a protocol like
IntegerArithmeticType but for floating point types?

Also, I don't know how many times I've found the need for this:
protocol DefaultInitializable { init() }

Yet there's nothing like that in the stdlib. Any particular reason for that?

(I'm sorry if this has been asked before but I couldn't find anything about
it.)

/Jens

Hi Jens,

Is there a reason why the standard library does not have a protocol like
IntegerArithmeticType but for floating point types?

Improving numerics support in Swift is a part of a long-term plan.

Also, I don't know how many times I've found the need for this:
protocol DefaultInitializable { init() }

Because there isn't a useful algorithm you can write on top of such a
protocol. It is even hard to write a doc comment for it -- what are
the semantics of calling that init? What is the postcondition?

Dmitri

···

On Thu, Mar 17, 2016 at 6:36 PM, Jens Persson via swift-dev <swift-dev@swift.org> wrote:

--
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@gmail.com>*/

Thanks!

···

On Fri, Mar 18, 2016 at 4:56 AM, Dmitri Gribenko <gribozavr@gmail.com> wrote:

Hi Jens,

On Thu, Mar 17, 2016 at 6:36 PM, Jens Persson via swift-dev > <swift-dev@swift.org> wrote:
> Is there a reason why the standard library does not have a protocol like
> IntegerArithmeticType but for floating point types?

Improving numerics support in Swift is a part of a long-term plan.

> Also, I don't know how many times I've found the need for this:
> protocol DefaultInitializable { init() }

Because there isn't a useful algorithm you can write on top of such a
protocol. It is even hard to write a doc comment for it -- what are
the semantics of calling that init? What is the postcondition?

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@gmail.com>*/

--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden

Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com