That's a good question.
I am working backwards from the fault.
If your -end- were being treated as you intended, as a Mata
statement, it would seem quite legal as such and there would be
no error message, and no problem.
Manifestly this is not happening. So what is happening? Your
-end- is being misinterpreted, so far as you are concerned,
and treated as a Stata statement. That's my diagnosis, and
evidently Maarten's too.
In general I am wary of calling anything a bug until I clearly
understand it to be such, and that view still applies for me
here until I hear otherwise.
The territory we are in may arise from the fact, as I understand
it, that -for*- loops in a sense define a kind of "program".
Within such contexts, -end- may be ambiguous.
Stata's rules evidently yield a Stata interpretation for -end-
in your code, and that's your problem.
(At one point, Mata ended with -mend-, but that didn't follow
through to release, and that decision is not reversible.)
There is some guesswork here. We need a StataCorp resolution.
Pablo Mitnik
Nick Cox wrote:
> The answer to your 2 is Yes, with some exceptions for good reasons, as
> when you call Stata from Mata, but that is not the issue as I
> understand it.
>
> The issue is that at that point in your code you are back in Stata and
> so (in context) -end- is illegal.
>
Why am I back in Stata at this point?
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/