Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
language:types [2022/05/13 12:32] – rajit | language:types [2025/04/21 14:32] (current) – [Parameterized types] rajit | ||
---|---|---|---|
Line 189: | Line 189: | ||
- | ===== Parameterized types ===== | + | ===== Parameterized |
Parameterized types give ACT considerable flexibility in type | Parameterized types give ACT considerable flexibility in type | ||
Line 208: | Line 208: | ||
brackets, as shown below: | brackets, as shown below: | ||
- | < | + | < |
int< | int< | ||
int< | int< | ||
Line 219: | Line 219: | ||
being sent and received on the channel. | being sent and received on the channel. | ||
- | < | + | < |
chan(bool) x; // x is a Boolean channel | chan(bool) x; // x is a Boolean channel | ||
chan(int< | chan(int< | ||
Line 226: | Line 226: | ||
The default data type for a channel is assumed to be the default | The default data type for a channel is assumed to be the default | ||
'' | '' | ||
+ | |||
+ | Channels are almost always unidirectional, | ||
+ | In a few cases, it is useful to be able to transfer data from the sender to the receiver, and from the | ||
+ | receiver to the sender in one channel action. To declare a channel where data are transferred in | ||
+ | both directions, use: | ||
+ | <code act> | ||
+ | // a bool is transferred from sender to receiver, and | ||
+ | // an int is transferred from the receiver to the sender | ||
+ | chan(bool, | ||
+ | </ | ||
+ | These are sometimes called //exchange channels//, since data is exchanged between the sender and receiver. | ||
+ | |||
Another built-in data type is the // | Another built-in data type is the // | ||
Line 231: | Line 243: | ||
restricted range. | restricted range. | ||
- | < | + | < |
enum< | enum< | ||
</ | </ | ||
Line 248: | Line 260: | ||
type can be defined, and they are shown below: | type can be defined, and they are shown below: | ||
- | < | + | < |
bool x; // Boolean that may be read or written | bool x; // Boolean that may be read or written | ||
bool! y; // Boolean that must be written, and may be read | bool! y; // Boolean that must be written, and may be read | ||
Line 263: | Line 275: | ||
output on '' | output on '' | ||
- | < | + | < |
defcell nand2 (bool? a, b; bool! c) { ... } | defcell nand2 (bool? a, b; bool! c) { ... } | ||
</ | </ | ||
Line 270: | Line 282: | ||
different. | different. | ||
- | < | + | < |
chan(int) x; // Sends or receives are permitted | chan(int) x; // Sends or receives are permitted | ||
chan!(int) y; // Only sends permitted | chan!(int) y; // Only sends permitted |