[WISH] formatted string literals

Discuss the future of the AutoHotkey language
jj4156
Posts: 19
Joined: 17 Jun 2019, 07:03
Contact:

[WISH] formatted string literals

Post by jj4156 » 10 Sep 2020, 09:34

While it's easy to done somehow by Implicit connection or continuation section in v1. But, something like f-string in python maybe more easier to use.
And %% deref in continuation section may be a good way for ahk formatted string literals.

Suggestion Example

Code: Select all

var := 123

; single line
string := f"some text %var% some text"

; multiline
string := f"
(
    other text %var%
    another text
)"
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: [WISH] formatted string literals

Post by burque505 » 10 Oct 2020, 10:40

@jj4156, I second that motion. See also JS template literals, and as shown at this SO post,

Code: Select all

string camlCondition = $@"
<Where>
    <Contains>
        <FieldRef Name='Resource'/>
        <Value Type='Text'>{(string)parameter}</Value>
    </Contains>
</Where>";
for verbatim string literal plus interpolation in C#.
Regards,
burque505
william_ahk
Posts: 482
Joined: 03 Dec 2018, 20:02

Re: [WISH] formatted string literals

Post by william_ahk » 16 Dec 2020, 01:25

In my opinion template literals in ECMAScript is the best. Variables are enclosed in left and right brackets like ${var}, making the string much more readable than %%
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [WISH] formatted string literals

Post by kczx3 » 16 Dec 2020, 09:50

I’m partial to template literals too
jj4156
Posts: 19
Joined: 17 Jun 2019, 07:03
Contact:

Re: [WISH] formatted string literals

Post by jj4156 » 22 Dec 2020, 01:12

william_ahk wrote:
16 Dec 2020, 01:25
In my opinion template literals in ECMAScript is the best. Variables are enclosed in left and right brackets like ${var}, making the string much more readable than %%
Since %% is already used as deref symbol in ahk in some situtations, I think %% deref where it could be used can make ahk more consistent.
Post Reply

Return to “AutoHotkey Development”