[swift-evolution] A (better) Swift Equivalent For The Classical For-Loop With Numeric Scalars
ted van gaalen
tedvgiosdev at gmail.com
Sat Mar 19 03:28:43 CDT 2016
Yes, thank you Dmitri, I think so too.
Will come back to this later.
TedvG
ted van gaalen
> On 19 Mar 2016, at 08:46, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>
> Hi Ted,
>
> Thank you for starting this thread. I agree that removing the C-style
> for loop has degraded the readability and clarity of some of numerics
> code.
>
> In the feedback to SE-0007 many people have said that they can convert
> their code to for-in loops, but I think this actually means that in
> code that is typically written in Swift today, loops primarily operate
> on sequences and collections. It means that numerics is a domain that
> not many people work in. But it is a very important domain
> nevertheless, and clarity for numerics code matters at least as much
> as it does everywhere else.
>
> I think one way to approach this discussion would be to present
> multiple concrete code samples that contain C-style for loops and are
> awkward to write without them. We can then try looking for patterns,
> generalize and simplify, and discuss possible solutions.
>
> 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>*/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160319/9075f2f8/attachment.html>
More information about the swift-evolution
mailing list