This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: foreach interation over specified index values in multiple index arrays


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]