Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| language:types2 [2026/08/05 15:07] – [Non-strict template parameters] rajit | language: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 type. Hence, when checking for type compatibility, | ||
| parameters are also taken into account. Hence, the full type for | parameters are also taken into account. Hence, the full type for | ||
| - | instance '' | + | instance '' |
| '' | '' | ||
| parameters are more completely specified as '' | parameters are more completely specified as '' | ||
| Line 463: | Line 463: | ||
| ... | ... | ||
| </ | </ | ||
| - | This will also result in the same circuit as the earlier example, because the value '' | + | This will also result in the same circuit as the earlier example, because the value '' |
| + | |||
| + | What if we wanted to create an array of these adders? While | ||
| + | <code act> | ||
| + | ... | ||
| + | addbuf< | ||
| + | </ | ||
| + | is fine, the problem arises if we want each '' | ||
| + | <code act> | ||
| + | addbuf< | ||
| + | addbuf< | ||
| + | </ | ||
| + | will result in the error message | ||
| + | < | ||
| + | -[ERROR]-> | ||
| + | Orig type: addbuf< | ||
| + | New type: addbuf< | ||
| + | </ | ||
| + | This is because elements of an array must have the same type. As this is a useful use-case, | ||
| + | |||
| + | Template parameters for processes | ||
| + | * //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 are separated from strict parameters by a vertical bar. The example above would be written as follows: | ||
| + | <code act> | ||
| + | template< | ||
| + | defproc addbuf(chan? | ||
| + | { | ||
| + | | ||
| + | chp { | ||
| + | *[ L?x; R!(x+VAL) ] | ||
| + | } | ||
| + | } | ||
| + | |||
| + | ... | ||
| + | addbuf< | ||
| + | addbuf< | ||
| + | ... | ||
| + | </ | ||
| + | ACT will allow this syntax. This comes with a few caveats: | ||
| + | * Any ports for the type can only use strict parameters. | ||
| + | template< | ||
| + | defproc oddbuf(chan? | ||
| + | { | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | -[ERROR]-> | ||
| + | </ | ||
| + | * 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. | ||
| + | |||
| + | Since the general ACT syntax can be used, the following would also be valid: | ||
| + | <code act> | ||
| + | ... | ||
| + | (i:8: addbuf< | ||
| + | ... | ||
| + | </ | ||