add example for static constant

This commit is contained in:
gluaxspeed 2021-10-21 11:31:40 -07:00
parent 5654e8a7a6
commit a34f36b9c1

View File

@ -64,6 +64,23 @@ let x = u8::MAX; // A constant value on the scalar type
let y = u8::to_bits(1u8); // A static method on the scalar type let y = u8::to_bits(1u8); // A static method on the scalar type
``` ```
It also allows for static constants for circuits in general:
```ts
circuit Point {
static SLOPE: u32 = 3;
x: u32;
y: u32;
function new(x: u32, y: u32) -> Self {
return Self {
x,
y: y + Self::SLOPE
};
}
}
```
## Drawbacks ## Drawbacks
This change adds more complexity to the language. This change adds more complexity to the language.