You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 range :
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= by calling init? Could we make it possible to implement init by calling init= ? Note that even if simple cases work here, init and init= have different strategies for instantiated or partially instantiated types (init uses additional arguments while init= uses this.type). Do we need some of the strategies from tertiary initializers to do this? (see issue tertiary initializers #17225).
Should the compiler automatically enable code like new list(myRange) to run list.init=(rhs: range) if no suitable list.init is 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 (issue Should the compiler be able to infer implied operations? #17200).
The text was updated successfully, but these errors were encountered:
#17200 (comment) discusses a case with list that might be a good motivating example but seems to propose that if one provides proc init(arg) then proc init= is inferred while the above proposes the opposite.
Today we have several data structures in the modules that implement both
proc init(rhs: rhsType)
andproc init=(rhs: rhsType)
for a variety ofrhsType
types. For example, there are these two functions implementing initialization of alist
from arange
:chapel/modules/standard/List.chpl
Line 250 in 4ebb0e3
chapel/modules/standard/List.chpl
Line 355 in 4ebb0e3
It seems to be unfortunate that these initializers need to be repeated. So, this issue asks two questions:
init=
by callinginit
? Could we make it possible to implementinit
by callinginit=
? Note that even if simple cases work here,init
andinit=
have different strategies for instantiated or partially instantiated types (init
uses additional arguments whileinit=
usesthis.type
). Do we need some of the strategies from tertiary initializers to do this? (see issue tertiary initializers #17225).new list(myRange)
to runlist.init=(rhs: range)
if no suitablelist.init
is available? This question is related to the question of whether or not the compiler can use aninit=
with an appropriate different type RHS to implement a cast (issue Should the compiler be able to infer implied operations? #17200).The text was updated successfully, but these errors were encountered: