aboutsummaryrefslogtreecommitdiff
path: root/examples/ptrs.fwd
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ptrs.fwd')
-rw-r--r--examples/ptrs.fwd22
1 files changed, 22 insertions, 0 deletions
diff --git a/examples/ptrs.fwd b/examples/ptrs.fwd
new file mode 100644
index 0000000..a0f8aac
--- /dev/null
+++ b/examples/ptrs.fwd
@@ -0,0 +1,22 @@
+fwd_null(auto x, () null, (&auto) ok);
+fwd_copy(auto x, (auto, auto) ok);
+fwd_println(auto x);
+fwd_intalloc((*int) ok);
+
+main()
+{
+ fwd_intalloc() => *int i;
+ fwd_copy(i) => *int i1, *int i2;
+
+ /* convert raw pointer to reference, unsure if this should be a
+ * built-in or a library feature */
+ fwd_null(i1) => {
+ fwd_println("Pointer was null");
+ /* error out or something */
+ } => &int i;
+
+ fwd_println(i);
+
+ /* Try uncommenting, deref of raw pointer is not allowed! */
+ // i* + 20 => int something;
+}