Interpolated string still not completely right

Type the following code:

var item1 := “123”;
var item2 := “234”;
var tst := $“an {item1}”;
var tst

The last line has coloring problems (color of a string).
During the typing you will see that the third line has red underlining (but will compile)
When you remove the fourth line, the last } will get red underlining.

change the third line in

var tst := $"an {item1} and ";

The word “and” become blue, but is part of the string (but will still compile)

If you add the next {item2} to the string, it is seen as comment, so no CC.

var tst := $"an {item1} and {item2} ";

Change the line to:

var tst := $“embedded interpolated string: {if item2=“123” then $“here is {item1}” else {item2})}”

It looks like:


And give the error:

When will this be supported?

Cant you just do for the Moment the usual way over string concationation?

It is often even more performant than Interpolation, of cause, depends on the internal implementation, but in MS C# (which sould be good optimized) you have this nice benchmark :slight_smile:

I use this for SQL statements, making it easy to copy / past it in the Management studio.
Because all vars are with {}, it is easy to replace them and run / test the query.

It is also easier typed and better readable - thus better maintainable.
It was never mend for performance.

The implementation of MS is String.Format.
But the good implementation should be:
step 1: remove the $
step 2: replace “{ by (
step 3: replace }” by )
step 4: replace { by " + (
step 4: replace } by ) + "

So:

var tst := $“embedded interpolated string: {if item2=“123” then $“here is {item1}” else $”{item2}“} and some more text”

after step 1:

var tst := “embedded interpolated string: {if item2=“123” then “here is {item1}” else “{item2}”} and some more text”

after step 2:

var tst := “embedded interpolated string: {if item2=“123” then “here is {item1}” else (item2}”} and some more text"

after step 3:

var tst := "embedded interpolated string: {if item2=“123” then “here is {item1) else (item2)} and some more text”

after step 4:

var tst := "embedded interpolated string: " + (if item2=“123” then “here is " + (item1) else (item2)} and some more text”

after step 5 (and done):

var tst := "embedded interpolated string: " + (if item2=“123” then “here is " + (item1) else (item2)) + " and some more text”

ah ok…

thats for sure, didnt thought of SQL-Code-base

btw, do you devlop SQL apps via oxygene or what exactly, just of curiosity

I do it in Oxygene (converting my VB codebase).
Almost everything I do is SQL Server based.

And that’s why I need / want the string obfuscation too; I use temporary encrypted stored procedures to make sure that the SQL code hidden from the SQL Profiler, but it can still be seen in my application.

Post withdrawn; aspect gives no syntax check.

Well it could, you can do a method aspect, something like:

var x := EncryptString($"some string goes here");

Where EncryptString is a global method aspect.

For the encryption: yes
For the interpolated string: no

then ? Shoudl work fine.

Back to basics.
See first post.

  1. The editor handling of the interpolated string is not optimal.
  2. Embedded interpolated strings do not work yet.

The string encryption is another story.

@ck
This is not marked as a bug - forgot or just not supported?

Thanks, logged as bugs://80650

Logged the editor handling. I’m still having a hard time seeing any real advantage to supporting nested interpolated strings, especially considering the massive amount of work it is to do so.

For now: Ok.

You can try to convince me though, with use cases

I vote against them. how deeply would they nest? can the nested interpolated stirring contain more nested interpolated strings? caudal they be 43 levels deeply nested in theory?

@mh: My goal is that I can anything with Oxygene that I can do with VB.
This is the only one left.

One use case in the first message.

In theory: yes
In practice: never more then 2 deep.