What is the current status of how variables are initialized?



There appears to be a lively ongoing debate about how elements of arrays should be inititialized, begun here and continued here. As I understand it, arrays of pointer types have their elements initialized to #undef. Arrays of primitive types are currently initialized to values that are defined (in the technical Julia sense) but unspecified, but there is ongoing debate as to whether the language should be changed so that arrays of primitive types are initialized to 0. I found the threads very hard to follow because they are so long, so I have a few questions:

  1. Are there types that are neither primitive nor pointer types, or do those two categories cover everything? If there are other types that are neither primitive nor pointer, how are they initialized in arrays?

  2. Am I correct that arrays of primitive types are still initialized to unspecified values? I got bogged down in the (extremely long) thread and may have missed a decision to change.

  3. Should the documentation be updated to clarify how array elements are initialized?

  4. I’m not clear whether the Google Groups and Github threads are addressing the same question. The Google Groups thread seems to be about how arrays are initialized. The Github thread seems to suddenly switch gears to discussing how fields of individual composite type objects should be initialized. Is it even possible to initialize a composite type object without explicitly initializing each of its fields?


Arrays of isbits types.

The two kinds of types are isbits and !isbits. So no there’s no overlap.


Yes. You can pass fewer arguments than field numbers.


I found the section Incomplete initialization in the documentation that answers my questions.

However, I would suggest updating the “Arrays” section of the documentation to specify that primitive/plain data types are initialized to unspecified values in arrays, while non-primitive data types are initialized to #undef in arrays. If one were trying to figure out how arrays work, it’s not at all intuitive to look in the “Incomplete Initialization” section of the documentation.