config
config copied to clipboard
Support Java7's Underscores in Numeric Literals
Would be great to support numbers like this:
long creditCardNumber = 1234_5678_9012_3456L;
http://docs.oracle.com/javase/8/docs/technotes/guides/language/underscores-literals.html
+1
Does it work to just remove underscores before doing the new BigInteger("123")? should be a simple patch. though I admit confusion on the credit card number example, aren't those usually treated as strings?
A PR for this should also have a patch to the HOCON.md spec probably with a link to the relevant java spec.
I think this is a semantic break unfortunately (because right now this will get parsed as a string). If you have 1_0 now and getString you could get "1_0", but with this change you would get "10". So this would have to be in an ABI-breaking (spec-breaking even) release, which we don't have a current concrete plan for but I have a github issues label to track such requests.
Since it's somewhat related (and has the same breaking problem), I decided to comment here instead of creating a new issue: is there a chance to get support for specifying integer settings in hexadecimal notation? I.e. "background = 0x00FF00". Would be really nice for color settings - sure I can do Integer.decode(config.getString(...)) (and will, for now), but having this integrated in the library for more homogenous errors would be neat.
Yeah basically that's an analogous situation with breaking things; but would be a simple change to make.
I don't think the getString should be modified and the original, raw value should be returned. This would match the behavior of using scientific notation:
# The maximum number of entries in the cache
maximum-size = 1e8
config.getString("maximum-size")
> 1e8
config.getLong("maximum-size");
> 100000000