[Swift-devel] Standard Library, take II

Mihael Hategan hategan at mcs.anl.gov
Mon Feb 2 17:26:37 CST 2015


On Mon, 2015-02-02 at 16:56 -0600, Tim Armstrong wrote:
> Oh I didn't realise there were keyword args in K.  So K supports optional
> arguments but the caller has to specify them by name, not position?

Yep. See
http://swift-lang.org/guides/trunk/userguide/userguide.html#_procedures

It's even funny at times:
"...both positional parameter and named parameter passings can be
passed..."

Mihael

> 
> - Tim
> 
> On Mon, Feb 2, 2015 at 4:18 PM, Mihael Hategan <hategan at mcs.anl.gov> wrote:
> 
> > 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