Last active
March 18, 2018 20:47
-
-
Save paniq/d8a93a5097f869f35a894aad41e05507 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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