Right now, interpol() is a perl wrapper calls the pp routine interpolate() and barfs if it returns an error status. (both at the pp level)
One could change interpolate() to do different things in a wantarray/scalar context... - but I do not think that is possible at the pp-level? It seems inefficient to add another layer of perl wrapping.. I only bring this up as interpol() was giving an annoying print, so I changed it to interpolate() and got unexpected results - perhaps the solution is simply to patch the documentation? (I remember this ‘feature’ from some code ten years ago and clearly forgot about it again…) K > On 17 Oct 2016, at 5:28 AM, Joel Berger <joel.a.ber...@gmail.com> wrote: > > We have explicitly removed all wantarray behavior from Mojolicious. In a web > context it basically will always be a security vulnerability waiting for an > unsuspecting application author. In PDL it is more likely to be a bug in > waiting than a vuln but you never know. > > On Sun, Oct 16, 2016 at 8:20 AM David Mertens <dcmertens.p...@gmail.com> > wrote: > Also, this works (append to end of Karl's example): > > -------- > ($y2) = interpolate $x2, $x, $y; > -------- > > These two routines differ in the context they expect to return to, and > interpolate's behavior is a known Perl wart. Stever Haryanto gave a nice > discussion of this Perl wart: > http://blogs.perl.org/users/steven_haryanto/2012/09/the-comma-operator.html > > To fix this, we should introduce yet another function with behavior that made > more sense in scalar vs list context. These routines, and their confusing > application of Perl's context, have been in the PDL codebase for a long time. > Presumably some folks have learned (probably the hard way) how to work around > these. I wouldn't want to pull the rug out from under them now. > > One word of warning about context-aware return values. I have written some > functions that do this, and I regularly find myself wanting the scalar return > value in list contexts like building a list of key/value pairs for a hash. In > that case, I must say "scalar(func(...))". I find myself doing this more > often than not, and wish I had never created the scalar/list differentiation. > > David > > On Sat, Oct 15, 2016 at 5:53 PM, Chris Marshall <devel.chm...@gmail.com> > wrote: > interpol() seems to be implemented in terms of > interpolate() already. Does seem a bit confusing. > Maybe the two routines could be merged into a > "smarter" interpolate()... > > --Chris > > On 10/15/2016 05:18, Karl Glazebrook wrote: > > Seems to me we should fix this inconsistency in usage? > > > > - Karl > > > > use PDL; > > $x = sequence(100); > > $y = $x**2; > > $x2 = sequence(10)*10; > > > > # This works > > > > $y2 = interpol $x2, $x, $y; > > print $y2, "\n"; > > > > # This does not work > > $y2 = interpolate $x2, $x, $y; > > print $y2, "\n"; > > # But this does > > ($y2,$err) = interpolate $x2, $x, $y; > > print $y2, "\n"; > > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > pdl-devel mailing list > pdl-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pdl-devel > > > > -- > "Debugging is twice as hard as writing the code in the first place. > Therefore, if you write the code as cleverly as possible, you are, > by definition, not smart enough to debug it." -- Brian Kernighan > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! > http://sdm.link/slashdot_______________________________________________ > pdl-devel mailing list > pdl-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pdl-devel > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! > http://sdm.link/slashdot_______________________________________________ > pdl-devel mailing list > pdl-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pdl-devel ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ pdl-devel mailing list pdl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-devel