#238 NiceSlice affects code where it should not

feature_request
open-remind
other (94)
7
2013-03-24
2010-06-20
punkish
No

I got the following error

DBD::Pg::st execute failed: ERROR: syntax error at or near "->"
LINE 2: CREATE TABLE test.foo ->nslice(CHECK(yr=...
^ at build_db.pl line 452.

The offending line in my script is

451>
452> $sth = $dbh->prepare(qq{
453> CREATE TABLE $table (
454> CHECK ( yr = $yr )
455> ) INHERITS ($schema.master_table)
456> });
457>

I was creating several tables where $table would be filled in before executing the statement, but NiceSlice's source filter changed the code causing the error. The error goes away if I precede the above code with

no PDL::NiceSlice

The solution is well-documented, but given that I have several different fragments of code that both use NiceSlice and get adversely affected by it, to me NiceSlice doesn't seem worth the trouble. I have to learn a syntax no matter what -- I may as well learn the regular slicing syntax instead of tinkering with NiceSlice, as my program is now littered with pairs of 'no PDL::NiceSlice/use PDL::NiceSlice'.

My env.

Mac OS X 10.6.4
perl 5.12.1
PDL 2.4.6

Discussion

1 2 > >> (Page 1 of 2)
  • Chris Marshall
    Chris Marshall
    2010-06-20

    Thanks for the bug report. Maybe something as simple as having a method call which would indicate that the arguments are to be NiceSlice filtered could help. e.g.,

    $a(1:10) could be written as $a->safeslice(1:10)

    It might even be useful as an option to preprocess arguments for the slice()
    method. Then the syntax with and without NiceSlice running globally could be the same.

     
  • Chris Marshall
    Chris Marshall
    2010-08-01

    Lowering the priority of this ticket since the feature
    requested is not on the critical path for the upcoming
    PDL-2.4.7 release. Deferring further enhancements
    in the NiceSlice source filter until after then.

     
  • Chris Marshall
    Chris Marshall
    2010-08-01

    • priority: 5 --> 3
    • milestone: --> feature_request
     
  • Chris Marshall
    Chris Marshall
    2010-10-07

    NiceSlice also fails to ignore POD sections in code
    and results in nslice() constructs appearing in POD.

     
  • Chris Marshall
    Chris Marshall
    2011-06-08

    This is to document progress towards improving PDL::NiceSlice.
    I've refactored PDL::NiceSlice to use Filter::Simple which supports
    ignoring POD, comments, and string contents for filtering.
    After tracking down a bug in Text::Balanced and one in Filter::Simple,
    the refactored PDL::NiceSlice passes tests as the original code but
    now ignores POD, comments, and strings.

    Once the bugs are resolved upstream, we can consider migrating
    to the Filter::Simple based code. In the meantime, the new code
    is in pdl git in the file Basic/SourceFilter/NiceSlice2.pm in case
    anyone wishes to give it a try. You'll need to refer to the perl bug
    reports at:

    http://rt.perl.org/rt3/Ticket/Display.html?id=92436
    http://rt.perl.org/rt3/Ticket/Display.html?id=92438

    to see the changes needed to the current Text::Balanced and
    Filter::Simple modules to get this to work. It looks promising
    so far....!

     
  • Chris Marshall
    Chris Marshall
    2011-07-16

    Assigning to myself since I've started work. Contributions and testing welcome.

     
  • Chris Marshall
    Chris Marshall
    2011-07-16

    • assigned_to: nobody --> marshallch
     
  • Chris Marshall
    Chris Marshall
    2011-10-10

    Bug fixed in Git.
    Thanks for reporting the problem!

     
  • Chris Marshall
    Chris Marshall
    2011-10-10

    • status: open --> pending-fixed
     
  • Chris Marshall
    Chris Marshall
    2011-10-10

    Example program for PDL::NiceSlice bug

     
    Attachments
1 2 > >> (Page 1 of 2)