-
Notifications
You must be signed in to change notification settings - Fork 610
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
Native Syntax: allow non-decimal integer literals #731
Comments
Hi! I'm not an HCL maintainer so this comment is not an answer on behalf of the HCL project. However, I am the maintainer of the HCL currently makes lots of use -- both direct and indirect -- of Relevant to this feature request, HCL relies on
These conversions intentionally use decimal representation exclusively. I don't intend to add upstream support for automatically converting None of this means that HCL's own parser could not allow alternative representations of numbers by implementing its own parser for producing a Lines 1132 to 1151 in ba07594
The main thing I'm trying to draw attention to is that it might potentially be confusing to allow numeric literals in other bases without also allowing string representations of those same literals to convert automatically to number values, and so HCL might also wish to take responsibility for number-to-string conversions too for consistency. However, that's ultimately a design tradeoff for the HCL maintainers to make; I have no particular opinion about it. Footnotes
|
Hello!
I'm considering HCL as a configuration language for an embedded software project. For this, it would be useful to have support for hexadecimal literals, maybe even binary and octal.
For simplicity reasons, I'm suggesting only a subset of Go's integer literals - some of the variations allowed there are not great for readability, especially octal literals like
07
or0O7
.Since go-cty supports unsigned 64bit integers, it would make sense to limit the numeric range to that (uint64_t).
For existing HCL files, there should be no compatibility issues as far as I can tell. numeric literals as specified today will still parse unchanged, the only additions suggested are number literals of the form:
0x12345678123ABCDE
0b00001111000
0o0666
Suggested Change in spec.md
Notes Regarding Readability and (in-)Consistency in the Spec
For consistency reasons, one might be tempted to allow
"0x" | "0X"
,"0b" | "0B"
and"0o" | "0O"
, given that today's langauge spec allows for upper case E and lower case e in numbers (1.0e5 == 1.0E5). I am not suggesting this here. As mentioned above, the octal prefix "0O" is too easy to misinterpret IMHO.The text was updated successfully, but these errors were encountered: