Thanks for the replies... I'll add a bit more now.
Let's assume that MOST uses of the getList() call would be to initially retrieve the list. We need to retrieve the list before we cycle over it, right? And further assume that the list was created much earlier and placed into a 'holding space'. Much like an attribute space on an HttpRequest (as an example).
What this implies, is that it has not 'been used' beforehand, and so one would naturally expect the list to be 'at the beginning' anyways. So now we have this situation.
The extra 'true' parameter is for the parameter named 'reset'. This particular call means "please give me the list, and reset it to the top". But what a pain in the bum, right? Of *course* I want the top of the list.. so shouldn't 'true' be the default value for reset? Seems resonable.
But wait...
And this is how I got burnt... I didn't realize the API had the two methods. I thought there was only getList(String name), and didn't realize that calling that one, was actually like calling getList(String name, boolean reset) with reset being defaulted to 'true'.
This is what I was doing, and I admit it looks odd, but believe me when I say, I'm under the hood of something, and for the sake of making *small* changes, I have to do it this way.
So you see the infinite loop, right?
My call to getList() on the "INNER" part resets it back to the top, because the default for the reset parameter is true. Remember it's pulling the same list from that nebulous 'attribute space'. If we were to watch the internal list pointer, it would be like a tennis match.
Kyle expressed my thoughts pretty well.
"HOLY SIDE-EFFECT BATMAN!"
But then there's this: Kyle also said:
I only allow side effects that could be resonably expected -- like initializing null variables to a reasonable default
Or... like I stated at the top of this post.. it's "reasonable" to assume a list is at the top of the list in 95% of the cases you'd call getList(). And so defaulting this method to reset the list is not a bad thing. Because who wants to type all of those trues, when MY particular example can be avoided by simply sending in 'false'.
But on the other hand.. if 95% of cases are for retrieving a list "for the first time"... wouldn't it be at the top anyways? And what about the programming chestnut of NEVER assuming something that is critical? If you want to ENSURE the pointer is at the top,
you should code it.
And Carl, I agree about the iterator! But there isn't one for this EList class I'm forced to use.
Thanks everyone for your replies.
[ February 13, 2002: Message edited by: Mike Curwen ]