chapel
chapel copied to clipboard
Feature Request: Extracting domain and type on variable assignment
It is very nice to bind the domain and type of a value that is not explicitly known:
proc makeArr() {
return [1,2,3,4,5];
}
proc runSomething(a: [?d] ?t) {
writeln(a, d, t:string);
}
runSomething(makeArr());
It would be convinient if the following syntax could be supported
var a: [?d] ?t = makeArr();
It could also just be treated as a shorthand for
var a = makeArr();
var d = a.domain;
type t = a.type;
This would also apply to situations where the element type is known, but the domain may vary.
var a: [?d] real = makeArr();
This request is somewhat related to https://github.com/chapel-lang/chapel/issues/10596 and also feels compatible with recent improvements to support increasingly generic type expressions for variable declarations, with the initializing expression filling in the missing details.