NamedArrays.jl icon indicating copy to clipboard operation
NamedArrays.jl copied to clipboard

There is not array getter

Open diegozea opened this issue 8 years ago • 4 comments

Now that array() was deprecated there is not an array getter. Could be great to have a getter (getarray or similar) in order to not access directly the array field.

Best regards,

diegozea avatar Jun 27 '17 11:06 diegozea

What is the advantage of having a getter like that over accessing the field?

Would Array() work for you?

---david ( 大卫)

Op 27 jun. 2017 13:46 schreef "Diego Javier Zea" [email protected]:

Now that array() was deprecated there is not an array getter. Could be great to have a getter (getarray or similar) in order to not access directly the array field.

Best regards,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/davidavdav/NamedArrays.jl/issues/52, or mute the thread https://github.com/notifications/unsubscribe-auth/AFPh10YXQFZGtcQPH_cUKBVXG0Gimvq9ks5sIOupgaJpZM4OGg4I .

davidavdav avatar Jun 27 '17 12:06 davidavdav

I believe that direct field access is discouraged in Julia, but I'm not sure. However, is good to have a stable getter in case that the internal array field change in the future. However, I'm moving my code to using *.array. Could Base.Array create a problem in the future?

diegozea avatar Jun 30 '17 16:06 diegozea

I can't really look into the future that well. Personally I don't know what the julia idiom is for these kind of type-conversion functions. I thought things like

n = NamedArray(...)
convert(Array, n)

and

Array(n)

are similar. However, now that I think of it, this probably doesn't solve your problem, as these construct new copies of the array.

There still is array(n) defined in NamedArrays as a getter function. We can promise to keep that if that makes you more comfortable.

davidavdav avatar Nov 23 '17 15:11 davidavdav

There's no problem. At the moment, I have defined my own getter to not write *.array everywhere in the code. I think that some aspects of Array construction are going to change in Julia 0.7/1.0. But, I'm not really sure. Can this decision wait for the release of 0.7?

diegozea avatar Nov 23 '17 15:11 diegozea