You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also there's related #11257, with a similar proposal for StringName conversions in general.
Describe the problem or limitation you are having in your project
Strings are currently implicitly created from char *:
booltest(char *inp) {
String s = inp;
// rhs is implicitly converted to String before concatenation, leading to unnecessary allocation.String("b") + U"";
}
This is leading to many cases of implicit conversions to String for all of String's wide array of functions.
The main problem with allowing this instead of making conversions implicit is that it takes attention away from the programmer. I have previously described how this has specifically lead to 40k lines of shader code being parsed multiple times unnecessarily. If the conversion was explicit, it is more likely that conversion would only have happened once.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Make conversion from char* to String explicit:
explicitString(constchar *p_str);
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Callers will have to adapt:
// Illegal
String s = "Test";
// Becomes
String s("Test");
Describe the project you are working on
#11249 to optimize strings.
Also there's related #11257, with a similar proposal for
StringName
conversions in general.Describe the problem or limitation you are having in your project
Strings are currently implicitly created from
char *
:This is leading to many cases of implicit conversions to String for all of
String
's wide array of functions.The main problem with allowing this instead of making conversions implicit is that it takes attention away from the programmer. I have previously described how this has specifically lead to 40k lines of shader code being parsed multiple times unnecessarily. If the conversion was explicit, it is more likely that conversion would only have happened once.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Make conversion from
char*
toString
explicit:Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Callers will have to adapt:
Macros and other convenience helperscshould probably be adjusted to accept string literals:
If this enhancement will not be used often, can it be worked around with a few lines of script?
Nope.
Is there a reason why this should be core and not an add-on in the asset library?
It's core.
The text was updated successfully, but these errors were encountered: