# Questions regarding bootstrapping the new Array constructors in boot.jl

**URL:** https://discourse.julialang.org/t/questions-regarding-bootstrapping-the-new-array-constructors-in-boot-jl/109110
**Category:** Internals & Design
**Created:** [January 22, 2024, 4:53pm UTC](https://discourse.julialang.org/t/questions-regarding-bootstrapping-the-new-array-constructors-in-boot-jl/109110 "2024-01-22T16:53:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [January 22, 2024, 4:53pm UTC](https://discourse.julialang.org/t/questions-regarding-bootstrapping-the-new-array-constructors-in-boot-jl/109110/1 "2024-01-22T16:53:39Z")

</div>

These are the core constructors for `Array` on master:

> <https://github.com/JuliaLang/julia/blob/406f5b44725287f6a2211eb7369fe67ae089891a/base/boot.jl#L572-L592>

1. The constructor methods that accept the dimensions as a series of `Int`s (as opposed to a tuple of `Int`s) come first, and they’re `eval`-ed into `Core`. Why the use of `eval` there, but not for the other constructor methods, below? EDIT: oh, I guess this is because they require `new` to be used.

2. I’m surprised that there’s so much code duplication? Is it necessary, or would it be possible to introduce additional helper functions to deduplicate the code?

3. Why use `getfield(d, 1), getfield(d, 2), getfield(d, 3)`, instead of just `d...`? Is this because of some special performance considerations that affect only bootstrapping?

I’m wondering about these issues because I want to fix a bug, but fixing it seems to require adding more of these core constructor methods to `base/boot.jl`. Github issue:

> <https://github.com/JuliaLang/julia/issues/53002>
>
> \`\`\`julia
> julia\> Vector{Union{}}(undef, 1)
> 1-element Vector{Union{}}:
> #undef
> …
> \`\`\`
> 
> Two issues:
> 
> 1. an array of type \`\<:AbstractArray{Union{}}\` must always be empty (because \`Union{}\` never has instances). So why is the object being \`show\`-n as "\`1-element Vector{Union{}}\`"?
> 
> 2. Given that \`\<:AbstractArray{Union{}}\` can never have elements (or, more precisely I guess, \`iterate\` will either return \`nothing\` or throw), trying to construct such an array with a nonzero length should throw.
> 
> The example above is by @tpapp in https://github.com/JuliaLang/julia/issues/52385#issuecomment-1903922191

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [January 22, 2024, 5:16pm UTC](https://discourse.julialang.org/t/questions-regarding-bootstrapping-the-new-array-constructors-in-boot-jl/109110/2 "2024-01-22T17:16:47Z")

</div>

I’m not 100% sure the duplication is necessary, but it might have been done to reduce the code size of the IR slightly. It would be good to check that it actually helps though.
