foreach interation over specified index values in multiple index arrays
Mike Mason
mmlnx@us.ibm.com
Wed Mar 7 22:52:00 GMT 2007
Frank Ch. Eigler wrote:
> Mike Mason <mmlnx@us.ibm.com> writes:
>
>> [...]
>> // stap doesn't like the 3 in foreach
>> foreach ([3, idx2] in arr) {
>> printf("%s\n", arr[3, idx2])
>> }
>> [...]
>
> We could support this syntax (interpreting literals as
> select/project). However, it would not be efficient to implement,
> since all keys are hashed together for the array indexing. It would
> be equivalent to
>
> # foreach ([__idx1, idx2] in arr) {
> # if (__idx1 != 3) continue
> # printf("%s\n", arr[3, idx2])
> # }
We can do this already, so if it can't be more efficient, I vote to leave the syntax as is. I'd rather not hide the inefficiency behind syntax changes, especially when traversing large multi-index arrays. Script writers need to know what's really happening.
I mainly ask because I thought I might be missing something. Would be a nice feature, but it's not high on my list.
Thanks,
Mike
>
> - FChE
More information about the Systemtap
mailing list