Questions regarding bootstrapping the new Array constructors in boot.jl

These are the core constructors for Array on master:

  1. The constructor methods that accept the dimensions as a series of Ints (as opposed to a tuple of Ints) 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:

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.

1 Like