From a34f36b9c15d88a3949413361ca5d6a11279f36b Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Thu, 21 Oct 2021 11:31:40 -0700 Subject: [PATCH] add example for static constant --- .../rfc/011-scalar-type-accesses-and-methods.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/rfc/011-scalar-type-accesses-and-methods.md b/docs/rfc/011-scalar-type-accesses-and-methods.md index 464ab87cc0..06f317fb10 100644 --- a/docs/rfc/011-scalar-type-accesses-and-methods.md +++ b/docs/rfc/011-scalar-type-accesses-and-methods.md @@ -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 ``` +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 This change adds more complexity to the language.