I'm assuming that in:
The mythical variable will get set to 4.
What happens with nested repeats?
Also, it doesn't quite work out very easily due to the way repeat currently works ... when a repeat is found we suck input to repeatend, without expanding anything (including macros). When repeatend/ending is found we gather up the stuff we've sucked out and push that back into the input stream the proper number of times.
Basically what's happening is that the repeat/end is being treated as special input and actually duplicated for later processing. So, now with a special variable, do we expand it as we create the copies or do we leave expansion until the copies are being processed? If we expand as we gather, we end up with a special case in the repeat loop which might be the best way ... leaving it will do not much other than have the same variable multiple times.
So, I guess what would need to be done is:
1. examine each line of the repeat chunk while the repeat block is being created,
2. see if our special loop counter is present anywhere in the line,
3. expand it and substitute,
3. continue.
It will not help in your example code which involves jumping out of a loop. Unless we completely rewrite the way it works, and I see no need for that when there are perfectly workable solutions right now (just a matter of setting a variable after the RepeatEnd. Remember, using RepeatEnd 0 will skip the section completely and RepeatEnd 1 will basically skip repeating.
Am I missing a problem?