Assignment expression for strings

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Assignment expression for strings

Post by Caligari87 »

From what I understand, the only way to concat strings is:

Code: Select all

statusMessage = statusMessage.."more status text";
While not awful, I feel this is a little needlessly verbose, and I end up doing a LOT of copy-pasting for it. Would it be possible to add an assignment expression? Such as:

Code: Select all

statusMessage ..= "more status text";
8-)
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Assignment expression for strings

Post by Major Cooke »

User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Assignment expression for strings

Post by Caligari87 »

While that is a useful method, I still feel like it's needlessly verbose, especially when I just want to concat something without the full array of formatting options. When applied here it only saves 3 characters from my example code (1 if I were to remove whitespace).

Code: Select all

statusMessage = statusMessage.."more status text";
statusMessage=statusMessage.."more status text";
statusMessage.AppendFormat("more status text");
To be fair, I don't know how hard it is to add another assignment expression to the parser. If it's a non-trivial, then that's fine. But += works for strings in C++ and Java, I don't see why we shouldn't also have it here (or at least some equivalent approximation of it).

8-)
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Assignment expression for strings

Post by Major Cooke »

At least with AppendFormat you don't have to repeat the variable name twice.
Post Reply

Return to “Feature Suggestions [GZDoom]”