20509, "benharsh", "Should user-defined field-accessors be deprecated?", "2022-08-25T16:11:58Z"
Currently I can write my own field-accessor for fields in a composite type:
record R {
var x : int;
proc x ref {
writeln("R.x accessor");
return x;
}
}
var r : R;
r.x = 5; // prints "R.x accessor" to stdout
This functionality was met with some surprise/unease over on #20472, which contains some discussion concerning the value of this feature (or lack thereof).
Should we deprecate this functionality?
A few points made on that issue:
proc x ref seems like something that would incur a "multiple definitions" error
Such a method seems more appropriate to "hide" a field (e.g. _x and x).
At one time, this may have been considered a logical conclusion to the implementation of compiler-generated field-accessors, and how we resolve field accesses