18006, "dlongnecke-cray", "Should Reflection functions prefixed with 'get' drop the 'get'?", "2021-06-30T17:34:53Z"
Should Reflection functions prefixed with get
drop the get
?
This issue proposes dropping get
prefixes from all functions in the
Reflection module.
So the following functions:
use Reflection;
record r { var x = 0; }
proc test() {
assert(getFieldName(r, 0) == 'x');
assert(getFieldIndex(r, 'x') == 0);
var r1 = new r();
assert(getField(r1, 0) == 0);
getFieldRef(r1, 0) = 1;
assert(getField(r1, 'x') == 1);
// These free functions query properties about the current scope.
var currentLine = getLineNumber();
var fileName = getFileName();
var currentFn = getRoutineName();
var currentMod = getModuleName();
}
Would become:
proc test() {
assert(fieldName(r, 0) == 'x');
assert(fieldIndex(r, 'x') == 0);
var r1 = new r();
assert(field(r1, 0) == 0);
fieldRef(r1, 0) = 1;
assert(field(r1, 'x') == 1);
// These free functions query properties about the current scope.
var currentLine = lineNumber();
var fileName = fileName();
var currentFn = routineName();
var currentMod = moduleName();
}
In #17984 the question is raised as to whether many of these functions
should be methods instead. If you'd be more likely to consider
dropping the get
from these functions if they were methods instead,
consider commenting in #17984 as well (if this is your position, then
you'd probably like the get
to stay for functions such as
getLineNumber
).