Discussion:
[Pdl-porters] Elegant means of dealing with optional PP piddle parameters?
Diab Jerius
2014-09-04 21:20:18 UTC
Permalink
My PP routine takes a number of piddles, some of which are optional. To
pass the signature check, *something* must be there (a null piddle won't
cut it, unfortunately), but I don't want to wastefully allocate unused
space. Currently the code does the following:

1. populate a bitmapped flag variable in OtherPars (but not(!) called
flags; see https://sourceforge.net/p/pdl/bugs/363/) recording the optional
piddles which are present
2. stuff an existing piddle of the right dimensions into the unused
optional piddle slots (I'm reusing a required piddle for this)

I'm not terribly thrilled with that approach; it seems a bit kludgy.

Any other means of accomplishing the same thing which is a bit more elegant?

Thanks,
Diab
David Mertens
2014-09-06 12:11:51 UTC
Permalink
Hey Diab,

This sort of approach is precisely what I do in PDL::Drawing::Prima to take
optional threadable arguments. However, you do not need to allocate a
piddle with full dimensions. A one-dimensional piddle of size 1 is
thread-compatible with anything.

David
Post by Diab Jerius
My PP routine takes a number of piddles, some of which are optional. To
pass the signature check, *something* must be there (a null piddle won't
cut it, unfortunately), but I don't want to wastefully allocate unused
1. populate a bitmapped flag variable in OtherPars (but not(!) called
flags; see https://sourceforge.net/p/pdl/bugs/363/) recording the
optional piddles which are present
2. stuff an existing piddle of the right dimensions into the unused
optional piddle slots (I'm reusing a required piddle for this)
I'm not terribly thrilled with that approach; it seems a bit kludgy.
Any other means of accomplishing the same thing which is a bit more elegant?
Thanks,
Diab
_______________________________________________
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...