Git Product home page Git Product logo

Comments (5)

sogaiu avatar sogaiu commented on July 19, 2024 2

@sarna I think this commit may have a relevant change:

$ janet
Janet 1.35.2-342a29c7 linux/x64/gcc - '(doc)' for help
repl:1:> (seq [i :range [0 5]])
repl:1:1: compile warning (normal): empty loop body
@[nil nil nil nil nil]

from janet.

sogaiu avatar sogaiu commented on July 19, 2024 2

FWIW, in the above case, the warning (that shows up on stderr) that appears for an empty-body loop broke a "driver" program that was parsing stderr. It had expectations that only certain output would show up on stderr (i.e. that coming from progams being executed).

I think in this case, the warning should actually not happen -- there seem to be legitimate reasons to have empty-bodied loops (in contrast to seq).

from janet.

sogaiu avatar sogaiu commented on July 19, 2024 1

I guess if one wanted 5 nils, it would be clearer to express it like:

(seq [i :range [0 5]] nil)

from janet.

sogaiu avatar sogaiu commented on July 19, 2024 1

Although the change introduced makes sense for seq, I'm not sure it does for loop.

I found an example here where an empty-body loop is being used for side-effects:

    (loop [line :iterate (file/read infile :line)
           :until (string/has-prefix? ">THREE " line)])

from janet.

sarna avatar sarna commented on July 19, 2024

With loop I think no warning is okay. seq is explicitly a list comprehension, so I'd expect the result to be used - not really true with loop.

from janet.

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.