-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Numbers and arbitrary precison #70
Comments
While bc is available on regular desktop linux environments it is missing in many "lite" cloud environments. It is not acceptable to rely on it, especially without checking at the top of the generated script to fail fast with a suitable warning. In general, anything that can be done with bash builtins without forking an external command should be done with builtins e.g. variable expansion substitutions instead of sed, case/esac globs, etc. Even if it is awkward, the performance difference is huge. Also, check all generated code with ShellSheck.net. |
Yeah, At first I wanted to make Amber feel more JavaScriptish so I decided to use the |
I just want to chime in that I agree about having an Int datatype that doesn't require bc. I was looking for something that compiled to bash so that I could make some software I'm thinking about distributing as easy to install and run as possible. Requiring cloud linux users to install bc just to run my software defeats the purpose. And I won't have need of anything beyond what an Int datatype would offer. I expect that's true for many potential projects that could otherwise use Amber. |
@Ph0enixKM there is a conversation happening on your reddit post related to this link. I'd like to say that I'm a big fan of a new integer type, as it would resolve to much "cleaner" integer comparisons. In regards to needing An interesting approach you could take, that would allow for the complete removal of VALUE=100
DIV=3
RESULT=$((${VALUE}00/$DIV))
echo "${RESULT:0:-2}.${RESULT: -2}"
33.33 This would obviously be a large and rather complex change. You could come up with a "scale" that is generally available for floating-point math. Something like 6 decimals would probably suffice, and any more precision would be up to the users to figure out (they can do the same integer math, if they so desire). Granted this is assuming a lot and definitely makes maintenance of the language much more challenging. The easiest approach would be to simply say "we don't support floating point arithmetic" and use only |
@eXamadeus Thank you for your point of view. I also think that we need to pivot the vision a little and simply add the Integer type to Amber. The closer we can get to readable bash, the easier it will be to read and debug! |
#95 mentions checking for The In general though, compiling to Bash is nice because it would provide some good bootstrapping capabilities, and might be all you need. My interpretation for Amber's niche in that using Bash-as-a-target, it can be used in very minimal environments, and ideally down to zero in some cases. For instance, to configure some environment you could load your compiled Crappy ASCII diagram
|
The solution would be the following: If |
Closed as duplicates for #70 |
So #381 tries to remove sed to clean up numbers and use the Maybe it is the first step... |
https://github.com/Ph0enixKM/Amber/blob/eedd6812c06885b8d1658c6b19246238bff7e489/src/translate/compute.rs#L51
I understand that bash cannot handle arbitrary precision numbers, but I think many users may prefer a low precision mode that does not generate pipelines like this.
There may also be an issue of
bc
not being installed on all systems.The text was updated successfully, but these errors were encountered: