From 563b1e2b285e788338aecfa9f3d6536fb9516fd0 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Thu, 19 Jan 2017 19:02:44 +0000 Subject: `immutable` field prefix --- code/demo.odin | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'code') diff --git a/code/demo.odin b/code/demo.odin index 4b4781323..272ef0ec2 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -10,6 +10,13 @@ #import "utf8.odin"; main :: proc() { + T :: struct { x, y: int } + foo :: proc(using immutable t: T) { + a0 := t.x; + a1 := x; + x = 123; // Error: Cannot assign to an immutable: `x` + } + // foo :: proc(x: ^i32) -> (int, int) { // fmt.println("^int"); // return 123, int(x^); -- cgit v1.2.3