Re: The scope of "Range foreach" depends on the number of invocation arguments
"eebel_igman" <[email protected]> Sat, 11 Aug 2012 22:24:53 -0000
| Newsgroups | gmane.comp.lang.io |
|---|---|
| Message-ID | <[email protected]> |
I found evidence for the described behavior in the source code:
IoRange.c, IoRange_foreach:
if (IoMessage_argCount(m) == 1)
{
return IoRange_each(self, locals, m);
}
If no index and no value argument is provided for the foreach, then IoRange_each is called. In IoRange_each, the message is performed on rd->curr as target:
IoMessage_locals_performOn_(doMessage, locals, rd->curr)
which is the current value of the range.
If at least a value or index and value are provided as arguments for the foreach, then the message is performed on the locals object as target:
IoMessage_locals_performOn_(doMessage, locals, locals)
Therefore the invocation target differs depending on the number of arguments. I suggest to adopt this subtile fact into the documentation about the Range foreach method.