[julia-users] immutable types with array fields

2014-09-13 Thread Pablo Zubieta
Hi everyone

I was wondering (since it seems that we are allowed to use array fields 
inside immutable types) if there are problems or any loose on the benefits 
of using immutable types if I do one of the following:


   1. Have an array field that is going to maintain its size but not the 
   values of its entries once the immutable is instantiated.
   2. Have an array field of variable size.
   3. Have an array field that will be unchanged.


I can't think of more scenarios for now, but I am curious of what could 
happen in general by using arrays as fields of immutables. May be I 
shouldn't be doing it at all. Does anybody know?


[julia-users] immutable types with array fields

2014-09-13 Thread Ethan Anderes
FWIW, I've done that before (immutable types, with array fields that change 
size and mutate entries) and i didn't run into any problems. I wasn't sure that 
I needed the immutability but I used it just for convenience. In particular I 
wanted to get an error if  I accidentally tried to rebind a field. Moreover, I 
figured it couldn't hurt the speed. 

I'll be interested to hear from others if I was doing something risky, 
confusing or non-idiomatic. 



Re: [julia-users] immutable types with array fields

2014-09-13 Thread Keno Fischer
Having an array as a field of an immutable is fine. It will be
variable size and heap allocated, just like if you had the array by
itself without the immutable. At some point we will tackle fixed-size
arrays (and the associated performance benefits) both mutable and
immutable.

On Sat, Sep 13, 2014 at 4:44 PM, Ethan Anderes ethanande...@gmail.com wrote:
 FWIW, I've done that before (immutable types, with array fields that change 
 size and mutate entries) and i didn't run into any problems. I wasn't sure 
 that I needed the immutability but I used it just for convenience. In 
 particular I wanted to get an error if  I accidentally tried to rebind a 
 field. Moreover, I figured it couldn't hurt the speed.

 I'll be interested to hear from others if I was doing something risky, 
 confusing or non-idiomatic.