Discussion:
[Pdl-porters] Typeloop #defines
David Mertens
2013-10-15 20:47:47 UTC
Permalink
Hey everyone -

I think we would make PDL::PP code potentially more legible by using the C
preprocessor instead of custom string handling. I am thinking particularly
about typeloops. Suppose that the threading engine set up the following
#defines in each type loop.

- When entering byte, #define PDL_BYTE_TYPELOOP 1 and #define
PDL_INTEGER_TYPELOOP 1
- When entering short, #define PDL_SHORT_TYPELOOP 1 and #define
PDL_INTEGER_TYPELOOP 1
- When entering long, #define PDL_LONG_TYPELOOP 1
--
"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
Craig DeForest
2013-10-15 20:49:46 UTC
Permalink
I like that.
Post by David Mertens
Hey everyone -
I think we would make PDL::PP code potentially more legible by using the C preprocessor instead of custom string handling. I am thinking particularly about typeloops. Suppose that the threading engine set up the following #defines in each type loop.
When entering byte, #define PDL_BYTE_TYPELOOP 1 and #define PDL_INTEGER_TYPELOOP 1
When entering short, #define PDL_SHORT_TYPELOOP 1 and #define PDL_INTEGER_TYPELOOP 1
When entering long, #define PDL_LONG_TYPELOOP 1
--
"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
_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
David Mertens
2013-10-15 20:49:55 UTC
Permalink
Sorry, that got cut off. Continuing where I left off:

- When entering long, #define PDL_LONG_TYPELOOP 1 and #define
PDL_INTEGER_TYPELOOP 1
- ...
- When entering float, #define PDL_FLOAT_TYPELOOP 1 and #define
PDL_FLOATING_POINT_TYPELOOP 1
- When entering double, #define PDL_DOUBLE_TYPELOOP 1 and #define
PDL_FLOATING_POINT_TYPELOOP 1

This way, I could conditionally add code using the C preprocessor rather
than the type stuff.
Post by David Mertens
Hey everyone -
I think we would make PDL::PP code potentially more legible by using the C
preprocessor instead of custom string handling. I am thinking particularly
about typeloops. Suppose that the threading engine set up the following
#defines in each type loop.
- When entering byte, #define PDL_BYTE_TYPELOOP 1 and #define
PDL_INTEGER_TYPELOOP 1
- When entering short, #define PDL_SHORT_TYPELOOP 1 and #define
PDL_INTEGER_TYPELOOP 1
- When entering long, #define PDL_LONG_TYPELOOP 1
--
"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
--
"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
Craig DeForest
2013-10-15 20:50:59 UTC
Permalink
:-) I was in the middle of typing your second half too...

Also PDL_INDEX_TYPELOOP...
When entering long, #define PDL_LONG_TYPELOOP 1 and #define PDL_INTEGER_TYPELOOP 1
...
When entering float, #define PDL_FLOAT_TYPELOOP 1 and #define PDL_FLOATING_POINT_TYPELOOP 1
When entering double, #define PDL_DOUBLE_TYPELOOP 1 and #define PDL_FLOATING_POINT_TYPELOOP 1
This way, I could conditionally add code using the C preprocessor rather than the type stuff.
Hey everyone -
I think we would make PDL::PP code potentially more legible by using the C preprocessor instead of custom string handling. I am thinking particularly about typeloops. Suppose that the threading engine set up the following #defines in each type loop.
When entering byte, #define PDL_BYTE_TYPELOOP 1 and #define PDL_INTEGER_TYPELOOP 1
When entering short, #define PDL_SHORT_TYPELOOP 1 and #define PDL_INTEGER_TYPELOOP 1
When entering long, #define PDL_LONG_TYPELOOP 1
--
"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
--
"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
_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
David Mertens
2013-10-15 20:58:47 UTC
Permalink
Yes, and unsigned short and longlong (i.e. quad). There may be other
combinations that are useful, besides the PDL_FLOATING_POINT_TYPELOOP and
PDL_INTEGER_TYPELOOP.

For example, PDL_BAD_TYPELOOP or PDL_GOOD_TYPELOOP may be useful here. I
find that most of my code for good and bad is quite similar, so being able
to introduce just a couple of changes could reduce the effort for PDL::PP
use. Right now I get around that by saving all of my code with placeholder
strings into a scalar<https://github.com/run4flat/PDL-Drawing-Prima/blob/master/lib/PDL/Drawing/Prima.pm.PL#L3385>,
then copying and modifying that scalar using regexes for the
good<https://github.com/run4flat/PDL-Drawing-Prima/blob/master/lib/PDL/Drawing/Prima.pm.PL#L3480>and
bad<https://github.com/run4flat/PDL-Drawing-Prima/blob/master/lib/PDL/Drawing/Prima.pm.PL#L3481>cases.

Hmm... I just realized *I* could add those #defines myself to play around
with it.

Anyway, those are my thoughts on that matter. Just more ideas for the
eventual PDL::PP overhaul. :-)

David


On Tue, Oct 15, 2013 at 4:50 PM, Craig DeForest
Post by Craig DeForest
:-) I was in the middle of typing your second half too...
Also PDL_INDEX_TYPELOOP...
- When entering long, #define PDL_LONG_TYPELOOP 1 and #define
PDL_INTEGER_TYPELOOP 1
- ...
- When entering float, #define PDL_FLOAT_TYPELOOP 1 and #define
PDL_FLOATING_POINT_TYPELOOP 1
- When entering double, #define PDL_DOUBLE_TYPELOOP 1 and #define
PDL_FLOATING_POINT_TYPELOOP 1
This way, I could conditionally add code using the C preprocessor rather
than the type stuff.
Post by David Mertens
Hey everyone -
I think we would make PDL::PP code potentially more legible by using the
C preprocessor instead of custom string handling. I am thinking
particularly about typeloops. Suppose that the threading engine set up the
following #defines in each type loop.
- When entering byte, #define PDL_BYTE_TYPELOOP 1 and #define
PDL_INTEGER_TYPELOOP 1
- When entering short, #define PDL_SHORT_TYPELOOP 1 and #define
PDL_INTEGER_TYPELOOP 1
- When entering long, #define PDL_LONG_TYPELOOP 1
--
"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
--
"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
_______________________________________________
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...