CAlive will introduce a
return { } block that can be traversed when a
returnout; command is encountered. Flow will immediately move to the start of the
return { } block, and all code there will be executed. Parameters will be allowed so custom values can be set for the exit.
function sample1
| params s32 a, s32 b, s32 c
| returns s32 total
{
s32 d;
// Derive d
d = calculate_d(a, b, c);
// If d is 0, use c and we're done
if (d == 0)
returnout(c);
// If d is shorter than a + b, we're done
if (a + b < d)
returnout(d);
// If we get here, it's invalid input
total = -1; // Just return a -1
} return (cd) {
// Our common return block
CAlive will introduce related { } blocks. Related blocks are added so that code can be identified as all being related to a function. The code inside the block can be rendered in the GUI in multiple different ways so as to highlight it, collapse it, indent it, etc., allowing for visual cues on the way a block of code is constructed.
Related blocks are designed to augment standard unnamed { } scope blocks, which can serve a similar purpose, but by explicitly indicating in source code these blocks are related, and giving it an optional name, the ability to tag, identify, and access various blocks of code within source code become possible.
function sample2
| params s32 count
| returns s32 total, s32 avg, s32 min, s32 max
{
s32 lnI, lnJ, a[count];
related init
{
// Populate our array
populate(&a);
// Ignore every negative value
for (lnI = 0, lnJ = 0; lnI < count; lnI++)
{
// Only keep zero or positive values
if (a[lnI] >= 0)
{
// Store the value unless we're in sync
if (lnI != lnJ)
a[lnJ] = a[lnI];
// Increase our count
++lnJ;
}
}
// Update our new max count
count = lnJ;
};
// Other code to calculate return values here
}
Thank you,
Rick C. Hodgin