Re: Working with views and values

2018-09-03 Thread Vanessa McHale
aptr(l) is an atomic pointer. I believe you can cast between prl(l) and aptr(l) though my C is not particularly good. And thanks! I'll have a look :) On 09/03/2018 09:09 PM, Hongwei Xi wrote: > What is aptr(l)? > > Here is some code that may be helpful: > > extern > fun > {a:vt0p} >

Re: Working with views and values

2018-09-03 Thread Hongwei Xi
If you just want to pass a value via call-by-reference, you can do fun{a:vt@ype} foo(x: a): ... = let var x = x // now the name 'x' refers to a variable, which is a form of left-value // that can be passed via call-by-reference ... ... On Mon, Sep 3, 2018 at 10:09 PM Hongwei Xi wrote:

Re: Working with views and values

2018-09-03 Thread Hongwei Xi
What is aptr(l)? Here is some code that may be helpful: extern fun {a:vt0p} ptr_alloc((*void*)) :<> [l:agz] (a? @ l, mfree_gc_v(l) | ptr(l)) // end of [ptr_alloc] extern fn {a:vt@ype} as_view(a): [l:addr | l > null] (a @ l, mfree_gc_v(l) | ptr(l)) implement {a} as_view(x) = let val

Working with views and values

2018-09-03 Thread Vanessa McHale
Is there any way to implement extern fn {a:vt@ype} as_view (a) : [ l : addr | l > null ] (a @ l | aptr(l)) extern fn {a:vt@ype} as_value {l:addr} ((a @ l | aptr(l))) : a ? I've tried using view@ and addr@ but it seems they're for stack allocations. I suppose I could write my own view in place