Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| language:expressions [2024/07/19 14:26] – [Bit-width rules] rajit | language:expressions [2025/04/21 17:39] (current) – [Structure references] rajit | ||
|---|---|---|---|
| Line 78: | Line 78: | ||
| * For concatenation, | * For concatenation, | ||
| * For bitfield extraction, the bitwidth is determined by the number of bits extracted. | * For bitfield extraction, the bitwidth is determined by the number of bits extracted. | ||
| + | |||
| + | ==== Idiosyncrasies ==== | ||
| While these bit-width rules are nice because you never lose bits, they can have some unexpected consequences. One of the not-so-nice effects of these rules is that, technically, | While these bit-width rules are nice because you never lose bits, they can have some unexpected consequences. One of the not-so-nice effects of these rules is that, technically, | ||
| Line 183: | Line 185: | ||
| } | } | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | ===== Structure references ===== | ||
| + | |||
| + | Functions can return [[language: | ||
| + | |||
| + | <code act> | ||
| + | deftype mystruct (int a, b) | ||
| + | { | ||
| + | | ||
| + | function getsum() : int | ||
| + | { | ||
| + | chp { | ||
| + | self := a + b | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | { | ||
| + | chp { | ||
| + | self.a := a + 1; | ||
| + | self.b := b + 1 | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | We can have expressions of the following form: | ||
| + | |||
| + | <code act> | ||
| + | mystruct s; | ||
| + | int a; | ||
| + | ... | ||
| + | chp { | ||
| + | ... | ||
| + | a := s.addone().getsum(); | ||
| + | ... | ||
| + | } | ||
| </ | </ | ||