http://www.freepascal.org/docs-html/3.0.0/prog/progap3.html
"nested procedures" not yet supported inside inline procedure/function.Inlining disabled.
Of course a subroutine can't call a nested>nested subroutine. It needs to be in the same scope the be able to call that routine.Code: Pascal [Select][+][-]procedure Foo; procedure a; procedure a_b; begin Foo; // can call Foo again (but watch out for recursion) end; begin a_b; //can call a_b end; begin a_b; // ERROR, can't call a_b a; // can call aend;
why?
Do you refer to something like?Quote"nested procedures" not yet supported inside inline procedure/function.Inlining disabled.I find the above hint ambiguous. It refers to something like:Code: Pascal [Select][+][-]procedure routine; procedure subroutine;inline; begin //Blah Blah end; begin //Blah Blah subroutine; //Blah Blahend;
Quote from: rabbit_dance on November 13, 2015, 04:34:03 pmwhy?Because procedure a_b is a subroutine of procedure a. It's only "local" accessible within the procedure a. The same goes for variables declared in procedure a. You can't call them from outside the procedure. (And when your in the main-part of procedure Foo, you're "outside" of procedure a, so can't access local variables and procedure declared within a).
how is nested subroutines being implemented?...i have some assembly knowledge of mmix.
and what causes the limitation occured?please interpret from the perspective of language implementation.
Quote from: rabbit_dance on November 14, 2015, 06:56:24 amhow is nested subroutines being implemented?...i have some assembly knowledge of mmix.Then you can just generate the assembly and analyze It's documented a little (well, the rest is the same as normal procedures): http://www.freepascal.org/docs-html/3.0.0/prog/progse23.htmlQuote from: rabbit_dance on November 14, 2015, 06:58:46 amand what causes the limitation occured?please interpret from the perspective of language implementation.Because stackframe for a_b (which requires a's stackframe) is not yet available when you call it. There's NO guarantee that a_b won't access anything declared locally in a so if a_b does, it may refer to invalid location. Well, of course such a check can be implemented at compile time but I think the language becomes inconsistent as sometimes you can call deeply nested procedure and sometimes can't.
all i want is the theoretical knowledge on the implementation of nested subroutine of pascal, and how to compile pascal code into mmix code.
Quote from: rabbit_dance on November 14, 2015, 09:43:51 amall i want is the theoretical knowledge on the implementation of nested subroutine of pascal, and how to compile pascal code into mmix code.Do you have knowledge about normal procedure implementation? If yes, nested procedure is the same, with the difference that there's a hidden pointer parameter pointing to parent procedure's stackframe, as explained in the docs. That's it.