Type inference: regression in 1.0?

Yes, new{ } is described in the manual chapter on constructors.

The key to understanding this is that there’s no real distinction between a constructor and a “callable type”. Every method definition can be written two ways: either by specifying the (singleton) instance of the called thing, or by specifying its type. So function f(x) can also be written as function (::typeof(f))(x). (Detail: the second form requires f to be assigned already.) For types, it looks like function Int(x) or function (::Type{Int})(x) but the idea is the same.

It’s quite possible the manual chapter should be rewritten not to refer to “inner” and “outer” constructors. The only distinctions that matter are (1) what type is the method defined for, and (2) is it written inside the struct block, giving it access to new. These two are completely orthogonal.

7 Likes