aboutsummaryrefslogtreecommitdiff
path: root/examples/references.fwd
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-01-09 22:26:02 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2025-01-09 22:26:02 +0200
commit598be4cd1bdd79e4859ae30291f4d65682cc672a (patch)
tree6e7e7ad537214c78049c4b3b2ee694c3b549fa4e /examples/references.fwd
parent6f7c2d6daa5c706d441ddc42c5c6409e5266049a (diff)
downloadfwd-598be4cd1bdd79e4859ae30291f4d65682cc672a.tar.gz
fwd-598be4cd1bdd79e4859ae30291f4d65682cc672a.zip
initial reference checking
Diffstat (limited to 'examples/references.fwd')
-rw-r--r--examples/references.fwd22
1 files changed, 22 insertions, 0 deletions
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;
+ };
+}