GithubHelp home page GithubHelp logo

Control flow for loops about infra HOT 6 CLOSED

annevk avatar annevk commented on June 5, 2024
Control flow for loops

from infra.

Comments (6)

domenic avatar domenic commented on June 5, 2024

HTML uses labels and "goto", but I guess that doesn't work great with foreach-style loops.

from infra.

annevk avatar annevk commented on June 5, 2024

Not opposed to both. URL has goto too, although rewrites have been requested for many of the same reasons it's avoided everywhere else...

from infra.

mikewest avatar mikewest commented on June 5, 2024

CSP uses "continue to the next item" in various places (https://w3c.github.io/webappsec-csp/#parse-serialized-policy for example). Since that's the way it's phrased in a variety of programming languages, phrasing it that way in the spec makes sense to me.

I'd suggest a template like the following:

  1. For each |item| in |list|:
    1. If we should skip |item| for some reason, continue to the next |item|.
    2. If we should stop the loop entirely, break.
    3. If we should skip out of this loop to a labeled step, continue to label.
    4. Do a thing to |item|.

from infra.

annevk avatar annevk commented on June 5, 2024

I like "continue to label". I wonder if we can just use "continue" for the other kind, since there's no real reason to make that phrase more complicated and mentioning the variable there makes it seem like you're passing an argument (which is a thing we do with "return" and "throw" and "continue to").

And maybe we should have break as well?

If X, then continue.
If Y, then continue to Z.
If AA, then break.

from infra.

mikewest avatar mikewest commented on June 5, 2024

SGTM.

from infra.

annevk avatar annevk commented on June 5, 2024

#56 discusses labels as well so I think we can leave that there for now and consider this fixed by @mikewest. (I'll post a PR for DOM to make use of the new concepts and get rid of the old language.)

from infra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.