Embedded underscores  
Author Message
Roedy Green





PostPosted: 2006-4-21 4:37:00 Top

java-programmer, Embedded underscores I noticed Ruby has a convention I wish Java would implement. I think
it could be done without breaking existing code.

You simply permit the _ character to appear embedded in numeric
literals in Java source code. The lead _ would not be permitted, so
you still have no trouble telling a number apart from an identifier.

Then you might write a numeric literal like this:

2006_12_31
or
123_456_679
or
0x1234_5678
or
250_361_9093
or
1000_99

The _ is simply ignored. You use it to break the number up in
whatever way you choose to make it more readable.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
The Ghost In The Machine





PostPosted: 2006-4-21 22:58:00 Top

java-programmer >> Embedded underscores In comp.lang.java.advocacy, Roedy Green
<email***@***.com>
wrote
on Thu, 20 Apr 2006 20:36:36 GMT
<email***@***.com>:
> I noticed Ruby has a convention I wish Java would implement. I think
> it could be done without breaking existing code.
>
> You simply permit the _ character to appear embedded in numeric
> literals in Java source code. The lead _ would not be permitted, so
> you still have no trouble telling a number apart from an identifier.
>
> Then you might write a numeric literal like this:
>
> 2006_12_31
> or
> 123_456_679
> or
> 0x1234_5678
> or
> 250_361_9093
> or
> 1000_99
>
> The _ is simply ignored. You use it to break the number up in
> whatever way you choose to make it more readable.
>

Did you want to modify the compiler (by e.g. creating a new class such
as CompilableInteger) or simply reimplement Integer.parseint()?

--
#191, email***@***.com
Windows Vista. Because it's time to refresh your hardware. Trust us.
 
Roedy Green





PostPosted: 2006-4-22 3:40:00 Top

java-programmer >> Embedded underscores On Fri, 21 Apr 2006 14:58:18 GMT, The Ghost In The Machine
<email***@***.com> wrote, quoted or indirectly quoted
someone who said :

>Did you want to modify the compiler (by e.g. creating a new class such
>as CompilableInteger) or simply reimplement Integer.parseint()?
No this is for the compiler only. You could always write you own
parseInt if that was what you wanted.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.