Dave Abrahams via swift-evolution <swift-evolution@...> writes:
> 
> 
> on Thu Apr 14 2016, Hans Huck <swift-evolution <at> swift.org> wrote:
> 
> > Dave Abrahams via swift-evolution <swift-evolution <at> ...> writes:
> >
> >> 
> >> If I thought extreme concision was important for this application, I'd be
> >> proposing something like 
> >> 
> >>   for x in 0.0..<20.0//1.3 {}
> >> 
> >> but personally, I don't,
> >>
> > And that is why exactly? The For-loop is at the very core of the language
> > and one of its most frequently used structures. Any unnecessary noise should
> > be avoided here.
> >
> >> which is why I propose `.striding(by: x)`
> >> rather than simply `.by(x)`, the latter being more open to
> >> misinterpretation.
> >> 
> > Please elaborate. How could
> >
> > for i in (1...10).by(3)
> >
> > possibly be misinterpreted?
> 
>   (p1..<p2).by(lineCount)
> 
> Doesn't exactly tell me what role lineCount is playing or what "by"
> does.  Maybe it means give me the range sorted by line count.  In this
> case a little more verbosity can be the difference between
> understandable and unmistakable.
> 

I find that unlikely, unless one is completely new to the language, but I
see your point -- for ranges in general.

It is impossible though to misinterprete it in the context of a For-loop, so
to keep the latter concise and the former unmistakable, what do you think of 

for i in p1..<p2 by x

as syntactic sugar for and internally mapped to

for i in (p1..<p2).striding(by: x)

Best of both worlds?

-- Hans


_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to