[Swift-devel] Standard Library, take II

Mihael Hategan hategan at mcs.anl.gov
Mon Feb 2 16:18:34 CST 2015


On Mon, 2015-02-02 at 15:46 -0600, Tim Armstrong wrote:
> I think that sounds good to me.
> 
> I think with overloading, I might attempt to implement overloading in the
> generic way (such that it would support user-defined functions), but only
> enable it for library functions by default.  This would let us experiment
> with it to see how it works, but reduces the possibility of bugs for the
> time being.
> 
> I think the keyword arguments needs some discussion.   I was thinking that
> we'd have optional positional arguments only (like C++).  I think in any
> case I'd like to put keyword arguments into the "future" category.  I'm
> open to discussion but I think we can put that off too.

They are already in K, but noted.

I'm inclined to change most library functions with keyword args (such as
substring(str, start, [end =...]) to overloaded ones, since there is no
good reason to write:

s1 = substring(s, 0);
s2 = substring(s, 1, end = 5);

rather than

s2 = substring(s, 1, 5);

I think that, from this perspective, overloading is roughly equivalent
to optional positional arguments. 

Mihael




More information about the Swift-devel mailing list