GithubHelp home page GithubHelp logo

Comments (3)

edubart avatar edubart commented on August 10, 2024 1

for the same reason that the built executable should

Detecting if the terminal is capable of printing colors at runtime would introduce a lot of baggage to every executable built by Nelua, with specific OS calls (such as isatty), something Nelua tries to avoid in favor of simplicity and compactness. Most of Nelua code is not dependent on OS functions, and even standard C functions are minimized, some people experiment with Nelua for building OS or to target consoles where there no standard C library available, this is why most Nelua builtin functions and standard library is made to be "freestanding".

If you give someone an executable that can't turn them off

Then that's a problem of the user who is distributing the executable, he has to choose to completely disable colors or not when building.

If the assert behavior is not ideal, it's possible to implement your own assert function with some runtime detection for colors.

from nelua-lang.

edubart avatar edubart commented on August 10, 2024

By default, the functions error, assert and check add source location and color codes, to make error messages more readable, both color codes and source location are dependent on the host environment the program is being compiled.

You could disable that with noassertloc pragma, however I have recently renamed the pragma to noerrorloc in commit b385d41.

So after updating, if you want to have a more reproducible executable when compiling in different environments, compile with -Pnoerrorloc to disable color codes and source location for all error messages in the final executable.

If you want to just disable colored output, you can compile with --no-color, it will disable coloring for the nelua compiler itself, but also disable the use of color codes in the final executable.

from nelua-lang.

jrfondren avatar jrfondren commented on August 10, 2024

The problem isn't reproducible executables, it's that executables emit color codes when they shouldn't do so. Nelua itself tests isatty for the same reason that the built executable should: because colors are nice to have at the terminal, and a problem to have in every other case - in a log, in an editor, in a pastebin when copying output to a github issue, etc.

Normally you would always want colors in your error messages, but if you give someone an executable that can't turn them off, in the same way that the nelua compiler turns them off, then you get bug reports like this:

/home/jfondren/nelua/nelua-lang/lib/stringbuilder.nelua^[[1m:349:12: ^[[31m^[[1mruntime error: ^[[0m^[[1minvalid format for argument^[[0m
    assert(false, 'invalid format for argument')
           ^[[1m^[[32m^^[[0m^[[35m~~~~^[[0m

from nelua-lang.

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.