Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
language:types2 [2026/08/06 10:33] – [Non-strict template parameters] rajitlanguage:types2 [2026/08/09 13:10] (current) – [Non-strict template parameters] rajit
Line 153: Line 153:
 the type. Hence, when checking for type compatibility, the values of the type. Hence, when checking for type compatibility, the values of
 parameters are also taken into account. Hence, the full type for parameters are also taken into account. Hence, the full type for
-instance ''a2'' above is in fact ''adder<5>'', not just+instance ''a2'' above is in fact ''adder<16>'', not just
 ''adder''. Types such as ''fulladder'' that do not have ''adder''. Types such as ''fulladder'' that do not have
 parameters are more completely specified as ''fulladder<>'', parameters are more completely specified as ''fulladder<>'',
Line 484: Line 484:
  
 Template parameters for processes can be of two types: Template parameters for processes can be of two types:
-   * //strict// parameters, are the ones we have been considering so far.+   * //strict// parameters, which are the ones we have been considering so far. Elements of an array must have the same strict template parameters.
    * //non-strict// parameters, which can be varied within an array.    * //non-strict// parameters, which can be varied within an array.
  
  
-Non-strict parameters are separate from strict parameters by a vertical bar. The example above would be written as follows:+Non-strict parameters are separated from strict parameters by a vertical bar. The example above would be written as follows:
 <code act> <code act>
 template<pint W | pint VAL> template<pint W | pint VAL>
Line 505: Line 505:
 </code> </code>
 ACT will allow this syntax. This comes with a few caveats: ACT will allow this syntax. This comes with a few caveats:
-    * Any ports for the type can only use strict parameters.  In other words, the type signature can only depend on strict parameters. This is what permits different process types to be treated as a single array, since the external interface to the array elements remains unchanged. +    * Any ports for the type can only use strict parameters.  In other words, the type signature can only depend on strict parameters. This is what permits different process types to be mixed within a single array, since the external interface to the array elements remains unchanged. So<code act> 
-   The array will be treated as a sparse array with multiple chunkseach of which can have different non-strict parameters.+template<pint W | pint VAL> 
 +defproc oddbuf(chan?(int<W>) L; chan!(int<W+VAL>) R) 
 +
 +...  
 +}  
 +</code>will lead to the following error<code> 
 +-[ERROR]-> Expressions in port parameter list can only use strict template parameters 
 +</code> 
 +   Even if the array is dense, it will be treated as a sparse array with multiple chunks where each chunk can have different non-strict parameters.
    * Sub-array expressions cannot be used where different elements have different types.    * Sub-array expressions cannot be used where different elements have different types.