20329, "benharsh", "Memory.Initialization: moveToValue function signature", "2022-07-29T16:42:17Z"
This is the current signature of moveToValue
:
proc moveToValue(const ref arg: ?t)
There are a couple of issues to raise here:
Return Type
The return type is empty. We should change this to either t
or arg.type
:
proc moveToValue(ref arg) : arg.type
proc moveToValue(ref arg : ?t) : t
The type query currently exists for some minor convenience inside the function body: t == nothing
and var result : t
.
The type query does not currently serve much of a purpose when the function body could use args.type
just as easily. Of course, if we used it as the return type then it would be more justifiable. This is really more of a broader question regarding our standard conventions (if they exist for this case, or what they should be).
Formal Name
Perhaps this is just my personal bias, but arg
feels a little casual. In Reflection.getField
we use the name obj
and have deprecated the versions with the formal name x
. I propose we do the same here:
proc moveToValue(ref obj: ?t) : t