On Saturday, June 6, 2015 at 3:42:11 PM UTC, Matt Bauman wrote:
>
> You questions seem to be predominantly focused on arrays.  The array 
> layout is very nicely specified (with lots of comments) here: 
> https://github.com/JuliaLang/julia/blob/01abdc3f2bc0e3611cf14aa331cdc6a10f0dfa0e/src/julia.h#L142-L178
>

Thanks.

Any reference to the code, would not answer point B. about if point A. (as 
shown below) would hold in the future.
 

>
> Also, take a look at the help for pointer_to_array: 
> http://docs.julialang.org/en/release-0.3/stdlib/c/#Base.pointer_to_array
>
> Those two things, taken together, I think will answer a lot of your 
> questions.
>

Yes and no?

"pointer_to_array(p, dims[, own])
Wrap a native pointer as a Julia Array object. The pointer element type 
determines the array element type. own optionally specifies whether Julia 
should take ownership of the memory, calling free on the pointer when the 
array is no longer referenced."

I meant an array already owned by Julia (allocated there), not sure this is 
it or what would happen if owned twice..

Thanks for leading the way to next in docs, however:

julia> a="Palli"
"Palli"

julia> b=pointer_from_objref(a)
Ptr{Void} @0x0000000005382400

Something like this is what I want:

julia> b=pointer_from_objref(a[3])
Ptr{Void} @0x00000000025b9210

[Note, how the address is completely different, because I guess this makes 
a new (here) single byte char or string copy.]

This seems to be the trick:

julia> b=pointer_from_objref(a)+2
Ptr{Void} @0x0000000005382402

but I'm not sure what happens when *a* dies. Not sure if something like 
this is what I want:

julia> b=pointer_to_array(pointer_from_objref(a)+2, 1)
1-element Array{None,1}:
 nothing

Reply via email to