1C:Enterprise script allows recursive procedure calls (calling a procedure from itself or more complex scenarios where a single procedure might be added to the call stack multiple times).
You can use recursive algorithms for various purposes, such as iterating hierarchical catalogs or processing subaccounts of a chart of accounts.
Note that each procedure call uses up a certain amount of stack memory reserved for performing this call. A proper exit from recursion is the responsibility of a configuration developer.
First of all, avoid scenarios with infinite recursion. The system behavior in a scenario with infinite recursion is described in Infinite recursion.
Also, avoid using algorithms where the number of recursion levels might reach hundreds. The script does not have built-in restrictions to the number of recursion levels but there is a technological restriction. Once the available resources are used up, the application is terminated. The recommended limit of recursion levels is several dozens.Next page: Specifics of reusing return values