#269 NiceSlice asterisk parsing issue

critical
closed-fixed
core (120)
5
2011-06-01
2011-05-11
No

Craig gave a reply in which he used an asterisk in a slice. I had forgotten that this was a (very, very useful) shorthand for inserting a dummy dimensions and this made me think of globs instead. Sure enough, when I ran it through the PDL shell I got the error "Not a GLOB reference". Here are some examples to illustrate the problem, from the pdl shell. I have put hashes in front of the printouts so you should be able to just copy-and-paste the text into your shell to see if it agrees.

First, behavior that makes sense:

------------------------%<------------------------
$data = sequence(5) # build sample piddle
p $data
# [0 1 2 3 4]

p $data(,) # first niceslice op, implicitly add a dummy dimension
# [
# [0 1 2 3 4]
# ]

p $data(:,*3) # Add dummy dimension of length three
# [
# [0 1 2 3 4]
# [0 1 2 3 4]
# [0 1 2 3 4]
# ]
------------------------>%------------------------

So far so good. Adding a dummy dimension makes it look like a 2-dimensional matrix.

Now check out what happens when I add a space between the comma and the asterisk:

------------------------%<------------------------
p $data(:, *3)
# [
# [0 1 2 3 4]
# ]
------------------------>%------------------------

That should have made a 2-dimensional matrix with dimensions 5,3, something identical to xvals(5,3). Something fishy going on here. It turns out that Perl interprets this as a glob. How do I know this? When I use an object that Perl does not know how to caste to a glob or glob reference, I get a helpful error:

------------------------%<------------------------
$second_dim = sequence(3); # build a second sample piddle

p $data(:,*$second_dim->nelem) # This gives what I expect from earlier
# [
# [0 1 2 3 4]
# [0 1 2 3 4]
# [0 1 2 3 4]
# ]

p $data(:, *$second_dim->nelem) # This croaks
# Not a GLOB reference
------------------------>%------------------------

The only difference between these last two is the presence or lack of a space between the comma and the asterisk.

As far as I can tell, this is not documented and I bet it's a NiceSlice parser issue. Furthermore, I bet it can be fixed without loss of backward compatibility since I don't know how anybody would have used this 'feature'.

Discussion

  • David Mertens

    David Mertens - 2011-05-11

    Output of perldl -V

     
  • David Mertens

    David Mertens - 2011-05-11

    Note this problem is unrelated to ticket 3295544, NiceSlice parsing bug, posted by Chris a few days ago. However, it looks like a review of NiceSlice is warranted.

     
  • Chris Marshall

    Chris Marshall - 2011-05-18

    Added to regexp for processing the '*N' args in NiceSlice.pm
    Marked Pending to close in 2 weeks unless there is further
    follow up this ticket. Thanks for reporting the problem.

     
  • Chris Marshall

    Chris Marshall - 2011-05-18

    Bug fixed in Git.
    Thanks for reporting the problem!

     
  • Chris Marshall

    Chris Marshall - 2011-05-18
    • assigned_to: run4flat --> marshallch
    • status: open --> pending-fixed
     
  • SourceForge Robot

    • status: pending-fixed --> closed-fixed
     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks