Feature - Implemented Template strings in ash!

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
I've been recovering from what was hopefully not coronavirus and wanting to do some programming without actually returning to my day job just yet, so here I am.

Like python's f strings and JavaScript's template strings, I wrote some changes to Parser.java to achieve the same thing for ASH. If you use backticks (`) to define a string, you can then use curly braces to concatenate expressions in a fashion that's a little more fluent and terse.

For example:

Code:
print(`Hello, {my_name()}! How are you doing today?`);

visit_url(`choice.php?pwd=&whichchoice=1395&pwd&option={pill}`);

I've tested it extensively, including various combinations of escaped tokens but still posting a patch here before I commit it to gauge if it's a desired feature as much as to sense check the code itself
 

Attachments

With the exception of the System.out.println() debugging calls, this looks pretty neat.
And useful. It obviates all sorts of explicit string concatenation with "+".
 
Last edited:
With the exception of the System.out.println() debugging calls

Whoops!

But thanks Veracity. I'll go ahead and merge it once I've sorted that.
 
Back
Top