This is an old revision of the document!


Assertions

Sometimes parameterized components are only valid for certain parameter ranges. ACT includes assertions that are checked at expansion time that can be used to validate the assumptions made.

As a simple example, suppose we want to define an N-place buffer.

template<pint N>
defproc buffer(chan?(int) L; chan!(int) R)
{
    onebuf b[N];   // create one-place buffer elements
    (i:N-1: b[i+1].L = b[i].R;)  // connect internal channels
    b[0].L = L; // connect external input
    b[N-1].R = R; // connect external output
}  

Passing in parameter 0 to this buffer would yield:

buffer<0> x;
--[ERROR]->  
In expanding ::<Global>
Error on or near line number XXXX
 id: b[0].L
FATAL: Identifer conditionally created, but used when it does not exist