PDLPorters/pdl

`use Inline Pdlpp` fails in autoloaded scripts specifically in `perldl` due to unsuppressable NiceSlicing

Closed this issue · 10 comments

Pdlpp code uses a lot of macros of the form $MACRO(params), which get turned by the NiceSlice filter into $MACRO->slice(params). That prevents the Pdlpp code from compiling. I recently updated PDL to the latest, and all my scripts with inline Pdlpp suddenly failed. I traced it to this issue. Even saying "no PDL::NiceSlice" in the code (which should suppress NiceSlice-ing below the "no" line) does not suppress the filtering.

I believe that anyone with inline Pdlpp code is currently unable to compile it.

Thank you for the report! Are you saying this is true in the latest PDL? I'm surprised because t/inlinepdlpp.t does test it, though it doesn't have NiceSlice.

Please could you post a script here so I can have some chance of repro-ing this?

I think it may be an interaction between the autocompiler and inline scripts. Here's a script that should, but does not, compile. Save as mandel.pdl in your PDL path and tell perldl "mandel()".

mandel.pdl.txt

Note: mandel.pdl (correctly) says "no PDL::NiceSlice" before the "use Inline Pdlpp" call, which switches off NiceSlice parsing as the file is executed. I haven't looked, but I suspect that the AutoLoader may be NiceSlice processing the entire eval string before executing it, which would override the "no PDL::NiceSlice" in the script itself (thereby corrupting the string being sent to Pdlpp).

I just ran it with perl -Mblib mandel.pl and it worked fine. It seems this is very specific to the Autoloader, which I don't use.

I have a repro case, added to t/autoload.t.

@drzowie I was wrong and I didn't, but that's for a very good reason. It's a bug in perldl. Try changing no PDL::NiceSlice to no main, and it will bizarrely work.

That's because perldl calls PDL::NiceSlice::perldlpp("main", ...) when it should call perldlpp("PDL::NiceSlice", ...).

By the way, a bit of digging in the history suggests this particular treat has lain in wait since at least 2015. Please try with an older PDL and see if it worked there.

Interesting. Thank you! Yeah, this code worked as recently as 2022, but I could have had an out-of-date perldl at that time.

I tried 2.019 and it seemed to work fine, so it looks most like one of the changes I made to NiceSlice will have subtly changed what those parameters mean. Sorry for the inconvenience.

By the way, I've been working on PDL::Graphics::Simple and making it able to do the graphics in the various PDL demos - I've had to add fits, contours, polylines. If you want to try them, then get the git master versions of P:G:S and PDL, and do demo in perldl to see the list. The aim is to generate web versions of all the demos (i.e. the output, with the images generated by P:G:S), and put them on the website.

Speaking of which, the PDL website recently got the whole PDL Book on there as one web page. Comments on all the above welcome!

p.s. Please could you fix the spelling of "autolaod" in your script? :-)