### Summary

Recursive function: using List() changes a variable too early

### Product

FileMaker Pro

### Version

FMP 12.0v1 (also 11v4)

### Operating system version

OS X 10.6.8

### Description of the issue

This one's puzzling me - I'm not sure why this happens, and I'm not positive I've found the most basic conditions in which the puzzling behavior occurs, but here goes anyway:

When I make a recursive function that makes use of global $$variables, if on the last iteration of the function I want to clear out a variable, I find that the variable is cleared too early (at the first iteration) if and only if I use a List() function. If I instead use a paragraph separator, the clearing occurs as expected.

### Steps to reproduce the problem

Let's imagine a function "Test" that's supposed to produce a list of numbers 1 through 5. I'll also add "(ended)" to the end so we can see when it terminates. Try this:

Let ( $$C = If ( $$C; $$C; 1 );

List ( $$C;

If ( $$C ≥ 5;

Let ( $$C = ""; "(ended)" );

Let ( $$C = $$C + 1; Test )

) // end If

) // end List

) // end Let

I get "(ended)" immediately. If, on the other hand, I replace that List() function with a paragraph separator, the function terminates where it should ("1¶2¶3¶4¶5¶(ended)").

Let ( $$C = If ( $$C; $$C; 1 );

$$C & ¶ &

If ( $$C ≥ 5;

Let ( $$C = ""; "(ended)" );

Let ( $$C = $$C + 1; Test )

) // end If

) // end Let

This leads me to conclude something about the List() function is somehow triggering the end-state Let() early, but I have no idea how or why that would happen. This also happens when I use local $variables in recursive functions, but that's another level of freakiness because recursive functions leave $variables persistent even though they're probably not supposed to be.

### Expected result

List() and ¶ shouldn't differ in how they cause a recursive function to handle variables.

Hi Dillik,

I don't think, this is a bug. The behavior is by design.

When you run the 1st cf, this function call is created (kind of simplified):

To calculate the 1st List function, FileMaker has to calculate the 2nd List function first. To calculate the 2nd List function, FileMaker has to calculate the 3rd List function first. And so on until FileMaker tries to calculate the 5th List function. But to calculate it, FileMaker has to calculate the Let function first. But here you already delete the global variable $$C. Therefore, when FileMaker finally is able to calculate the 5th List function $$C is already empty. The same happens with the 4th, 3rd, 2nd, and 1st List function.

Arnold Kegebein