Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Sunday December 17, 2006
06:21 PM

My First Pugs Test

[ #31942 ]

I've had commit access to the Pugs project for a long time but haven't done much with it. I fixed some stuff in CGI, wrote the first translation of HTML::Entities and started the examples/cookbook project (largely untouched), but that was about it. Today, in trying to solve 99 Perl 6 problems, I ran into a bug.

my @array = <a b c d e f g h i j k>;
@array.splice(3, 5).perl.say;

That prints 'h', instead of of the list. I hopped onto the #perl6 IRC channel and asked about this and Luke found the problem in src/Pugs/Primhs:

-- op4 "splice" = \x y z w-> do
op4 "splice" = \x y z w -> do
    splice  <- doArray x array_splice
    start   <- fromVal y
    count   <- fromVal z
    vals    <- fromVals w
    vals'   <- splice start count vals
    ifListContext
        (return $ VList vals')
        (return $ last (undef:vals'))

The ifListContext says that if we're in list context, return the list, otherwise, return the last value from it. He changed that to this:

-- op4 "splice" = \x y z w-> do
op4 "splice" = \x y z w -> do
    splice  <- doArray x array_splice
    start   <- fromVal y
    count   <- fromVal z
    vals    <- fromVals w
    vals'   <- splice start count vals
    return $ VList vals'

I then committed a test to verify that this works. I really want to learn Haskell so I can do this myself, but for now, I'll keep working on my 99 problems.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.