forget memorized table columns
Table columns referenced with fixed column names, e.g. [table:Last Name,1], or simply [Last Name] where context infor are available for partial table specifications, B4P will automatically memorize the matching column number for the name provided in order to accelerate performance significantly when additional references are made, e.g. in loops or procedures processing table rows such aslike table process. The acceleration is achieved by checking the column position for the header name provided only once, memorize the column number and use it afterwards.
Benefits: | Very high performance |
Drawbacks: | If the same table access statement is executed with a different table where the row has changed, then the column will be referenced. |
See the code exmaple further below for wanted and unwanted effects.
Implicitly memorizing column numbers can be suppressed with following options:
Indirect parameter passing is disabled
0
table initialize ( table 1,
{ { Animal, leg count }, { Bird, 2 }, { Dog, 4 }, { Fly, 6 } } );
table initialize ( table 2,
{ { Animal, weapon, leg count }, { Snake, poison, 0 }, { Tiger, teeth, 4 }, { Lobster, claws, 8 } } );
define procedure ( legs, { { table name, string } } )
{
table process( table name[], echo( [Animal],": ", [leg count], " and ", [(leg count)] ) );
echo; // Note the parentheses around (leg count)
}
legs( table 1 );
echo("Hmmmm - Something is strange here ...");
legs( table 2 ); // Note the mistake outputting the first 'leg count' value.
echo("Forget memorized table columns: ");
forget memorized table columns;
legs( table 2 ); // This one is OK
echo("If you set runtime settings[memorize table columns] to false, output will always be OK");
runtime settings[memorize table columns] = false;
legs( table 1 );
legs( table 2 ); // All output will be right. But looking up continuously may slow performance a bit.
Bird: 2 and 2
Dog: 4 and 4
Fly: 6 and 6
Hmmmm - Something is strange here ...
Snake: poison and 0
Tiger: teeth and 4
Lobster: claws and 8
Forget memorized table columns:
Snake: 0 and 0
Tiger: 4 and 4
Lobster: 8 and 8
If you set runtime settings[memorize table columns] to false, output will always be OK
Bird: 2 and 2
Dog: 4 and 4
Fly: 6 and 6
Snake: 0 and 0
Tiger: 4 and 4
Lobster: 8 and 8
memorized table columns