Syntax of types with "new" in constructors, where is it described?

I ran into the issue described in How to resolve syntax: too few type parameters specified in “new{…}”? yesterday and for the life of me I can’t find anywhere in the documentation where the syntax new{A,B,C} is even mentioned/used much less described in the documentation.

Is there something I missed? or does the documentation need a pull request to include some description of how this works?

Where I looked:
The keyword “new” is described here: Essentials · The Julia Language

and it refers you to here:
https://docs.julialang.org/en/v1/manual/constructors/#man-inner-constructor-methods

I guess at the very bottom of that page is a mention of new{A,B} but it’s pretty sparse on details. It seems useful to have something right in the section labeled “Parametric Constructors”

2 Likes

It does seem to be under-documented.

Documentation is something I could potentially provide a pull request for without a major problem.

I’m thinking the docstring on “new” should say:

  new, or new{A,B,...}

  Special function available to inner constructors which creates a new object
  of the type. The form new{A,B,...} calls out the types explicitly similar to a constructor
  for a struct such as Array{Int,1}. See the manual section on Inner Constructor Methods for more
  information.

or something like that. Then in the section on Parametric Constructors, any suggestions?

1 Like

Nice idea!

I’d drop the “similar” part though, as new is reserved for inside of inner constructors and per se has nothing to do with how a parametric type is written - just that the “type parameters” in new{..} define how the constructed object is parametrized.

1 Like

ok, I opened a PR with this edit for the “new” docs