At what moment are the #'s taken?
All # are taken at the beginning! of code execution.
At what moment are the selects taken?
All select statements are taken at the moment when they are executed! This is a fundamental difference from #.
At what moment are the @'s taken?
@ is syntactic sugar for select — similarly at the moment of their execution.
Example in which a misunderstanding of the sequence leads to an error
Suppose we have three fields field_1, field_2, and field_3. We create an action code in field_2:
a1= : set(table: $#ntn; field: 'field_1' = 25; where: 'id' = #id)
a2=: set(table: $#ntn; field: 'field_3' = #field_1; where: 'id' = #id)
The first action changes the value in field_1, and the second takes the value from field_1 and sets it in field_3.
As a result of executing this code, the value in field_3 will be taken from field_1 before the change. Suppose it was 11.
Despite assigning 'field_1' = 25, field_3 will be 11 because its value through # will be taken before the action code execution begins!
Let's modify it to work:
a1= : set(table: $#ntn; field: 'field_1' = 25; where: 'id' = #id)
a2=: set(table: $#ntn; field: 'field_3' = $select; where: 'id' = #id)
select: select(table: $#ntn; field: 'field_1'; where: 'id' = #id)
This code will work because the select call is made after field_1 is changed.