Skip to content

Instantly share code, notes, and snippets.

@paniq
Last active March 18, 2018 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paniq/d8a93a5097f869f35a894aad41e05507 to your computer and use it in GitHub Desktop.
Save paniq/d8a93a5097f869f35a894aad41e05507 to your computer and use it in GitHub Desktop.
struct Val
x : i32
y : i32
fn new (val)
let mval = (malloc (typeof val))
# option A: wrap pointer in a fancy reference type
let mval = (('from-pointer-type reference (typeof mval)) mval)
mval = val
# option B: keep as regular pointer, just do a simple store
store val mval
mval
let testval =
new (Val 1 2)
assert (testval.x == 1)
assert (testval.y == 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment