Discussion:
[Pdl-porters] Updates needed for non-core PDL based distributions
Chris Marshall
2013-10-15 15:25:48 UTC
Permalink
To PDL Developers-

With the official release of PDL-2.007 with 64bit indexing
support, there is a need to update existing PDL-based
modules to handle the now possibly 64bit values.

Ideally, all modules would be updated to handle builds
before and after the introduction of the new PDL_Indx
data type. The way to do that is to:

(1) Determine if you have PDL_Indx data support.
The easiest way is to load PDL and check if
defined(&indx).

(2) If not, the original code should work as before

(3) If so,you'll need to change places where your code
assumes that the PDL index value is a 32bit int
and replace it by PDL_Indx in C code, or the indx
type in perl/PDL code.

(4) Ideally, add tests for any new capability

(5) Document if your module is 64bit safe (builds and
runs) or 64bit capable (in the sense that you can
use 64bit piddle data and indexes/offsets)

My current plan is to keep CHM/PDL-2.006.tar.gz on
CPAN indefinitely (which means until all the existing
external code is updated). Given that fact, you can
also require your module to use no version of PDL
greater than 2.006. That would work around the problem
in a technical sense but you could lose the planned
enhancements in type support... coming.

It would be useful for someone to write some sort of
adapter code that could be used to simplify the update
or even automate the compatibility entirely. As always
code and patches are welcome.

Regards,
Chris
David Mertens
2013-10-15 20:44:50 UTC
Permalink
Hey everyone -

For the most part, .pd files should not need modification. However, I found
that my PDL::Drawing::Prima needed a tweak in a section that had different
code for different types, i.e. something like this:

types(BSULQ) %{
/* integer-based handling here */
%}
types(FD) %{
/* floating-point handling here */
%}

In my code, I had to insert the index type, but only if found. First, I
queried PDL::Types for the single-character used for
PDL_Indx<https://github.com/run4flat/PDL-Drawing-Prima/blob/master/lib/PDL/Drawing/Prima/Utils.pm.PL#L495>.
If PDL::Types doesn't know about the type, it silently returns undef, which
I replace with an empty string. Then, I insert the type character (or the
empty string) into my list of
types<https://github.com/run4flat/PDL-Drawing-Prima/blob/master/lib/PDL/Drawing/Prima/Utils.pm.PL#L513>.
Note that PDL::PP pulls in PDL::Types, so you can query this function
without pulling in a module in your .pd files.

It's not the prettiest code in the world, but it gets the job done in a
relatively legible way. It also reminds me that I would like to have an
alternative means for inserting conditional code like this, which I'll
suggest in an alternative email.

Hope that helps!
David
Post by Chris Marshall
To PDL Developers-
With the official release of PDL-2.007 with 64bit indexing
support, there is a need to update existing PDL-based
modules to handle the now possibly 64bit values.
Ideally, all modules would be updated to handle builds
before and after the introduction of the new PDL_Indx
(1) Determine if you have PDL_Indx data support.
The easiest way is to load PDL and check if
defined(&indx).
(2) If not, the original code should work as before
(3) If so,you'll need to change places where your code
assumes that the PDL index value is a 32bit int
and replace it by PDL_Indx in C code, or the indx
type in perl/PDL code.
(4) Ideally, add tests for any new capability
(5) Document if your module is 64bit safe (builds and
runs) or 64bit capable (in the sense that you can
use 64bit piddle data and indexes/offsets)
My current plan is to keep CHM/PDL-2.006.tar.gz on
CPAN indefinitely (which means until all the existing
external code is updated). Given that fact, you can
also require your module to use no version of PDL
greater than 2.006. That would work around the problem
in a technical sense but you could lose the planned
enhancements in type support... coming.
It would be useful for someone to write some sort of
adapter code that could be used to simplify the update
or even automate the compatibility entirely. As always
code and patches are welcome.
Regards,
Chris
_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
--
"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
Loading...