Previous: , Up: Blocks   [Contents]


3.1.4 Subblocks

When combining and pipelining blocks, a special field called #:subblocks is updated. This field indicates how the final block was built.

When combining blocks, the subblocks are set as a list. For example,

(block-subblocks
 (combine-blocks* a b)) ;=> `(,a ,b)

Combining more blocks will append to the list.

(block-subblocks
 (combine-blocks* (combine-blocks* a b) c)) ;=> `(,a ,b ,c)

When running a pipeline, the subblocks of each pipeline element are inserted into a list. Elements without subblocks are inserted directly.

(block-subblocks (run-blocks*
                  (combine-blocks* a b)
                  c d)) ;=> `((,a ,b) ,c ,d)

A side effect of this is it is impossible to tell by looking at the #:subblocks field alone whether a block created by running a pipeline or by combining blocks. A block created by running a pipeline of blocks that were not previously combined would look identical to a block created by combining blocks.

The elements of the #:subblocks field are the original blocks. When running a pipeline, the blocks are not executed directly. Instead, the #:code field is updated by replacing #:chain, and that new block is the one that executes. However, that is not reflected in the subblocks. The subblocks #:code field will not be replaced.