[Swift-devel] New syntax for appending to arrays

Mihael Hategan hategan at mcs.anl.gov
Tue Jun 28 12:50:02 CDT 2011


On Tue, 2011-06-28 at 23:07 +0530, Yadu Nand wrote:
> Hi Mihael,
> 
> > There have been some schools of thought in language design that said
> > that there should be one and only one way to do a certain thing.
> I planned on implementing both methods, += operator as well as append()
> so that once its done, it'd be easier to decide which is better.
> Should I drop implementation for append() style ? I'm ok with that.
> 
> I'd like to point out one issue that came up between a discussion with
> Justin today. I am using the earlier idea of the append being an assign
> with the array subscript being the thread prefix.
> Meaning  array["key"] += 10  is [1]converted to  array["key"]["!"] = 10 by
> the parser.
> There is still the possibility that the user may inadvertently use the string
> "!" as subscript and create weird situations. So instead of "!" we could use
> a string say "_SWIFT_AUTO_INCREMENT" . This being something used
> internally.
> 
> [1] Well not converted exactly, but the kml generated is the same.

Well, don't. Make it generate something else, like path=getThreadIndex()
instead of path="_SWIFT_AUTO_INCREMENT".




More information about the Swift-devel mailing list