I thought the purpose of a block in Maxima was to protect global variables from being accidentally reassigned; however, I am not totally clear on the roles / rules for the different parts of a block.
For example, if one defines the function:
function():=
block(
[
a:1,
b:2,
c:a,
d:b
],
[c,d]);
);
executing this function yields function(); >> [ a, b ]. Initially, I expected [ 1 , 2 ]; however, after consulting the documentation, I saw that it says:
Note that the assignments in the block variables, are done in parallel.
Which I take to mean that, in the above, c:a and d:b are being assigned to the as-yet-undeclared variables a and b.
As such, if I wanted to have variables that depend on other variables, within a block, would the correct way of doing this be:
function():= block([ a:1, b:2 ], block([ c:a, d:b], [ c, d]) );
It seems to give the correct result, but this seemed a bit circuitous to me, so I couldn't help but wonder if there were a more direct approach? It's also not clear to me when it is important to declare variables in the [ ] section (do the parts of the block have a name?). Any insight would be greatly appreciated.