[swift-evolution] [Pitch] Replace 'inout' with '&'

Matthew Johnson matthew at anandabits.com
Sat Dec 19 08:50:34 CST 2015

> On Dec 18, 2015, at 8:52 PM, Dmitri Gribenko via swift-evolution <swift-evolution at swift.org> wrote:
>> On Fri, Dec 18, 2015 at 6:21 PM, Joe Groff <jgroff at apple.com> wrote:
>> On Dec 18, 2015, at 6:08 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>> There's also a possibility that we add 'out' parameters in the future, and
>> if 'inout' would be spelled '&', then we would need to find another sigil
>> for 'out'.
>> We have multiple returns. Why would we ever add out parameters?
> I don't want to turn this thread into a discussion about out
> parameters, but one reason would be to replace
> AutoreleasingUnsafeMutablePointer.  Another one is to add labels to
> the output parameters:
> let (day, month, year) = parseDate()
> let (year, day, month) = parseDate() // bug?

I haven't had a need for multiple returns yet although I'm really glad they are in the language.  They are much nicer than out parameters.  

I'm really surprised if it isn't possible to use labeled tuples for multiple returns.  It seems like that should be possible either now or in the future.  (If I was at a computer right now I would try it)

> 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>*/
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list