Comments (3)
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.
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.
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)
- (@span(byte)){...} ordered field cast permits invalid, rejects valid construction HOT 1
- <comptime> record parameters can't be provided; fields can't be used in runtime code HOT 1
- Copyright timespan needs update HOT 3
- Invalid unitname generated for directories that look like numeric literals HOT 1
- No line number in error if a hashmap index has a type error
- Range check error messages point to library code (point of check) rather than user code (point of error) HOT 1
- Function variables can collide with C identifiers HOT 1
- Confusing errors with varargs
- Permit function returns in generic instantiation, not just types
- Broken preprocessor after 9faaa66e HOT 3
- Comparison of a pointer with nil generates unexpected C code HOT 2
- we need nelua debugger(vscode) or tell us how to debug my app? HOT 2
- Compatible with Lua C plug-in HOT 2
- LFS: can't change directory with `lfs.chdir` HOT 1
- error while compiling when a source file starts with a number HOT 1
- Compiler hangs when cgenerator.lua errors
- Can't compile fibonacci example
- Can't compile fibonacci example
- Support actual closures via struct
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nelua-lang.