The spec says, and NQP seems to implement (Rakudo, I think, picks up
<integer> from NQP as defined in HLL-s0.pir, is this right?) that a
single underscore is ignored between any two digits in a number, not
between the radix and the number. However, it seems to me that this
would be very handy:

 0b_1111_0000 instead of 0b1111_0000
 0x_dead_beef instead of 0xdead_beef
 0d_1_000_000 instead of 0d1_000_000

... just in terms of the clarity gain from keeping the radix at arms
length from the rest of the integer literal.

Just a thought.

I tried this change against parrot to test it out, but it didn't seem
to make any difference, so I must be missing something:

$ svn diff parrot/ext/nqp-rx/src/stage0/HLL-s0.pir
Index: parrot/ext/nqp-rx/src/stage0/HLL-s0.pir
===================================================================
--- parrot/ext/nqp-rx/src/stage0/HLL-s0.pir     (revision 47640)
+++ parrot/ext/nqp-rx/src/stage0/HLL-s0.pir     (working copy)
@@ -2759,6 +2759,13 @@
     substr $S10, rx184_tgt, $I11, 1
     ne $S10, "b", rx184_fail
     add rx184_pos, 1
+    add $I11, rx184_pos, 1
+    gt $I11, rx184_eos, rx184_nobunder
+    sub $I11, rx184_pos, rx184_off
+    substr $S10, rx184_tgt, $I11, 1
+    ne $S10, "_", rx184_nobunder
+    add rx184_pos, 1
+  rx184_nobunder:
   # rx subrule "binint" subtype=capture negate=
     rx184_cur."!cursor_pos"(rx184_pos)
     $P10 = rx184_cur."binint"()
@@ -2778,6 +2785,13 @@
     substr $S10, rx184_tgt, $I11, 1
     ne $S10, "o", rx184_fail
     add rx184_pos, 1
+    add $I11, rx184_pos, 1
+    gt $I11, rx184_eos, rx184_noounder
+    sub $I11, rx184_pos, rx184_off
+    substr $S10, rx184_tgt, $I11, 1
+    ne $S10, "_", rx184_noounder
+    add rx184_pos, 1
+  rx184_noounder:
   # rx subrule "octint" subtype=capture negate=
     rx184_cur."!cursor_pos"(rx184_pos)
     $P10 = rx184_cur."octint"()
@@ -2797,6 +2811,13 @@
     substr $S10, rx184_tgt, $I11, 1
     ne $S10, "x", rx184_fail
     add rx184_pos, 1
+    add $I11, rx184_pos, 1
+    gt $I11, rx184_eos, rx184_noxunder
+    sub $I11, rx184_pos, rx184_off
+    substr $S10, rx184_tgt, $I11, 1
+    ne $S10, "_", rx184_noxunder
+    add rx184_pos, 1
+  rx184_noxunder:
   # rx subrule "hexint" subtype=capture negate=
     rx184_cur."!cursor_pos"(rx184_pos)
     $P10 = rx184_cur."hexint"()
@@ -2814,6 +2835,13 @@
     substr $S10, rx184_tgt, $I11, 1
     ne $S10, "d", rx184_fail
     add rx184_pos, 1
+    add $I11, rx184_pos, 1
+    gt $I11, rx184_eos, rx184_nodunder
+    sub $I11, rx184_pos, rx184_off
+    substr $S10, rx184_tgt, $I11, 1
+    ne $S10, "_", rx184_nodunder
+    add rx184_pos, 1
+  rx184_nodunder:
   # rx subrule "decint" subtype=capture negate=
     rx184_cur."!cursor_pos"(rx184_pos)
     $P10 = rx184_cur."decint"()

--
Aaron Sherman
Email or GTalk: a...@ajs.com
http://www.ajs.com/~ajs

Reply via email to