Open DaAlbrecht opened 2 days ago
I think perhaps a pretty low-hanging fruit would be to just add an extra run command flag bal run -d/r
for debug/release (or add it to the existing one bal run --debug <port>
and make the port optional) and add it as a default module-level variable.
We already have configurable variables. I would be inclined to handle this by having a module in the standard library that provides a configurable variable that is automatically set to true or false depending on whether it's a debug or release build. WDYT @sameerajayasoma
Isn't this the same thing that we discussed earlier where a config value could be statically set (say from a file or a parameter)?
We already have configurable variables. I would be inclined to handle this by having a module in the standard library that provides a configurable variable that is automatically set to true or false depending on whether it's a debug or release build. WDYT @sameerajayasoma
Yea exactly what i mentioned earlier. It wouldn't be conditional builts but is easier to implement and gives already a lot of the usability benefits
Isn't this the same thing that we discussed earlier where a config value could be statically set (say from a file or a parameter)?
I think this is already possible: https://ballerina.io/learn/provide-values-to-configurable-variables/
The difference is i would like that ballerina sets this config value automatically without me having to set or unset it.
There is a discussion on this topic in Discord initiated by @DaAlbrecht and that thread has more details. https://discord.com/channels/957996897782616114/1301578394944798750/1301578394944798750
We already have configurable variables. I would be inclined to handle this by having a module in the standard library that provides a configurable variable that is automatically set to true or false depending on whether it's a debug or release build. WDYT @sameerajayasoma
The workaround that doesn't require any changes right now is to define a configurable variable (say DEBUG) and configure it via the command line. I believe @DaAlbrecht is already doing this. I believe this approach is good enough for now.
configurable boolean DEBUG = false;
bal run -- -CDEBUG=true
I am thinking for a bit more first-class conditional compilation solution that would even work for nBallerina as well. Here are some requirements:
Description:
Having conditional compilations in Ballerina (Debug / Release Build) would be pretty helpful or at least setting Debug / Release Flags automatically.
This would allow the user just to check if the Debug flag is set and use this to instrument their applications with extra debug logic without needing to set this flag themselves.
Inspiration from Rust:
cfg: checks https://doc.rust-lang.org/rust-by-example/attribute/cfg.html#cfg
This allows for a nice syntax like
Suggested Labels: enhancement, langlib, design/usability