Git Product home page Git Product logo

Comments (3)

bradcray avatar bradcray commented on June 10, 2024

I'm definitely open to that argument, but before we jump into it: Note that, currently, the standalone underscore isn't allowed in for-loops either. That is,

for _ in 1..10 do writeln("Hi!");

also generates a syntax error. I believe that the original intention was that _ was for dropping tuple elements on the ground since one could write the for loop as:

for 1..10 do writeln("Hi!");

and the square bracket form as:

  private var globalBarrier = [BarrierSpace] new unmanaged aBarrier(1, reusable=true, procAtomics=true, hackIntoCommBarrier=true);

(which shows how square bracket syntax and array declarations are really just type vs. value variations of the same thing).

So, I think what we currently have is consistent and reasonable, but that there's a question as to whether we'd want to extend both cases to support a standalone _ as well. Upside: Maybe _ in is clearer than just omitting it? Downside: two ways to write the same thing.

An intermediate approach would be to replace the syntax error with a suggestion to just drop the _ in expression.

from chapel.

DanilaFe avatar DanilaFe commented on June 10, 2024

I hadn't considered that. For some reason, I was perfectly happy removing the index from for loops (and did it without trying _), but went for _ in bracket loops. There might be something to be said there about "intuitiveness" but probably it's just that I've seen no-in for loops, but not no-in bracket loops. I'm content with your answer and would be good with closing the issue, unless others want to continue the discussion.

from chapel.

DanilaFe avatar DanilaFe commented on June 10, 2024

No complaints then. Closing 😄

from chapel.

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.