Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
drzowie opened this issue Sep 13, 2024 · 10 comments

Comments

@drzowie
Copy link
Contributor

drzowie commented Sep 13, 2024

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.

@mohawk2
Copy link
Member

mohawk2 commented Sep 13, 2024

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.

@mohawk2
Copy link
Member

mohawk2 commented Sep 13, 2024

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

@drzowie
Copy link
Contributor Author

drzowie commented Sep 13, 2024

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

@drzowie
Copy link
Contributor Author

drzowie commented Sep 13, 2024

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).

@mohawk2
Copy link
Member

mohawk2 commented Sep 13, 2024

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.

@mohawk2
Copy link
Member

mohawk2 commented Sep 13, 2024

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

@mohawk2 mohawk2 changed the title "Use Inline Pdlpp" fails due to unsuppressable NiceSlicing "Use Inline Pdlpp" fails in autoloaded scripts due to unsuppressable NiceSlicing Sep 13, 2024
@mohawk2
Copy link
Member

mohawk2 commented Sep 13, 2024

@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", ...).

@mohawk2 mohawk2 changed the title "Use Inline Pdlpp" fails in autoloaded scripts due to unsuppressable NiceSlicing use Inline Pdlpp fails in autoloaded scripts specifically in perl due to unsuppressable NiceSlicing Sep 13, 2024
@mohawk2 mohawk2 changed the title use Inline Pdlpp fails in autoloaded scripts specifically in perl due to unsuppressable NiceSlicing use Inline Pdlpp fails in autoloaded scripts specifically in perldl due to unsuppressable NiceSlicing Sep 13, 2024
@mohawk2
Copy link
Member

mohawk2 commented Sep 13, 2024

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.

@drzowie
Copy link
Contributor Author

drzowie commented Sep 13, 2024

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

@mohawk2
Copy link
Member

mohawk2 commented Sep 14, 2024

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? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants