From 598be4cd1bdd79e4859ae30291f4d65682cc672a Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 9 Jan 2025 22:26:02 +0200 Subject: initial reference checking --- examples/references.fwd | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/references.fwd (limited to 'examples/references.fwd') diff --git a/examples/references.fwd b/examples/references.fwd new file mode 100644 index 0000000..468f4a0 --- /dev/null +++ b/examples/references.fwd @@ -0,0 +1,22 @@ +references(&int a, &int b, () r) +{ + /* don't have assignment and not quite sure if I want to have to + * dereference references so I guess we can't really do much here at the + * moment, heh */ + r(); +} + +main() +{ + 20 => int twenty; + 30 => int thirty; + references(twenty&, thirty&) => { + 20 + 30 => int fifty; /* ok */ + }; + + /* references are not active anymore so we can reference again */ + references(twenty&, thirty&) => { + /* not ok since twenty/thirty is actively borrowed */ + twenty + thirty => int fifty; + }; +} -- cgit v1.2.3