17199, "mppf", "should 'new R(arg)' be able to run a 'proc init=' ?", "2021-02-19T18:30:03Z"
Today we have several data structures in the modules that implement both
proc init(rhs: rhsType) and
proc init=(rhs: rhsType) for a variety of
rhsType types. For example, there are these two functions implementing initialization of a
list from a
It seems to be unfortunate that these initializers need to be repeated. So, this issue asks two questions:
- Should it be possible to implement one of these by calling the other? Does it work today to implement
init? Could we make it possible to implement
init=? Note that even if simple cases work here,
init=have different strategies for instantiated or partially instantiated types (
inituses additional arguments while
this.type). Do we need some of the strategies from tertiary initializers to do this? (TODO tertiary initializers issue).
- Should the compiler automatically enable code like
new list(myRange)to run
list.init=(rhs: range)if no suitable
list.initis available? This question is related to the question of whether or not the compiler can use an
init=with an appropriate different type RHS to implement a cast. (TODO cast issue).