In the YAPC::Asia Hackthon, done a really awesome hacks on PerlX::Range module with flora -- We re-implement it with XS approach so it works more robust.
The current (version 0.04) implementation is to use
replace the statements like:
To something like
1 + PerlX::Range->new(last => 100)
This can be easily broken in many ways (inappropriate precendence, random syntax errors, etc).
The new approach is to do it in XS with
replace the flipflop range OP with a manually built entersub OP.
which returns a PerlX::Range object.
The current XS base implementation is in the xs branch on github, take a look if you're interested.
Here are some brief examples to try:
# build into blib/ first perl Makefile.PL; make; # => PerlX::Range perl -Mblib -MPerlX::Range -E 'say ref(1..10000)' # => 10000; perl -Mblib -MPerlX::Range -E '$r = 1..10000; print $r->items' # => 10000; perl -Mblib -MPerlX::Range -MData::Dumper -E '$r = 'a'..'z'; say Dumper($r)'