One approach to having a true-negative indexed array is by defining
an object-oriented approach. A set of tied-array-based methods might
provide the most natural approach. That should allow a transparent mapping
of negative array indices onto a perl zero based array implementation
while avoiding a string based (hash) array that might result in reqiring
more memory to store the same amount of information and more CPU resources
to do array element store and fetch operations. Such a set of methods
might utililize a definition mechanism that specifies the lowest and
highest array indices for an array, e,g, @array=new negarray(-30,-10);
The base property for the array would be 30, the value that would have
to be added to each index value to translate it back to a zero-based
perl array implementation. Such an array would also be created with
a index-limit property of 20. Such an approach would allow each array
to have it's own base index value rather than using the $[ mechanism
which defines an array base value that is used for all arrays. Note,
this mechanism could still allow perl-style negative indexing for
calculating actual index values relative to the end of an array, ,i.e.
$array[-9] could still be used to fetch the last element of
the negarray @array. This of course would not be limited to array with
just negative indices. There would be no reason which such an array
could not be defined as having elements having lower/upper limits
defined as -10:+20 or +30:+80 so long as the lower limit was less than
or equal to the upper limit.

**** [EMAIL PROTECTED] <Carl Jolley>
**** All opinions are my own and not necessarily those of my employer ****

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to