19928, "arezaii", "Should 'sourceVersion' continue to prepend 'version ' when cast to string?", "2022-06-02T19:08:15Z"
In the process of trying to add a non-param type that supports reasoning about program versions at runtime (How to add a non-param type similar to `sourceVersion` · Issue #19201 · chapel-lang/chapel · GitHub), I have proposed removing the version
that gets prepended to the output when casting an object of this type to a string.
For example, a sourceVersion
of 1.2.3
will print version 1.2.3
when cast to a string.
The rationale for removing this are:
- Including it forces the user to remove
version
and replace it with something else rather than append it only when needed. For example, if my program needed to output its version information likev1.2.3
instead, I'd have to do the cast and then do a replacement.
e.g.,
// if we leave version in the output
writeln((v1_2_3:string).replace("version ","v"));
// instead of
writeln("v" + v1_2_3:string);
- I am not sure what precedence there is for including additional information when casting simple types to string. Do we have other simple types that also do this? Is
sourceVersion
special enough to warrant always adding text information to the casted output?