Close

Argentum got string interpolation

A project log for Argentum programming language

It automatically prevents all memory leaks. It doesn't use GC, so no pauses. It's compiled to machine code. It's crazy safe and fast.

andrey-kalmatskiyAndrey Kalmatskiy 05/18/2023 at 14:050 Comments
result = db.query("{}
     SELECT name, id
     FROM users
     WHERE name LIKE '{ encodeSql(request.userMask) }%'
     LIMIT {request.page * xPageSize}, {xPageSize};
");
request.mode == Json
   ? response.send(result.toJson())
   : response.send("{}
        <ul>{
            result.forRecords((record) { "{}
                  <li data-id="{  record["id"]  }">
                      {  record["name"]  }
                  </li>
            "})
        }</ul>
    ")

 In this example we use string interpolation twice:

This SQL query is a simple multiline text string with { placeholders } . Placeholders are Argentum expressions that return everything convertible to strings.

HTML example demonstrates two nested interpolated strings - one for <ul> and one for nested <li>s.

More on string interpolation: here.

Discussions