On 2/28/20 5:17 AM, Jacob Carlborg wrote:
On Friday, 28 February 2020 at 03:10:48 UTC, Walter Bright wrote:

I don't know Swift, but this looks like the "generate strings and concatenate them" approach.

No, it basically lowers to bunch of method calls. Here's an example of how it could look like with D syntax:

auto a = 3;
auto b = i"foo $a bar";

Could be lowered to:

auto _temp = StringInterpolation(8 /* literal capacity */, 1 /* interpolation count */);
_temp.appendLiteral("foo ");
_temp.appendInterpolation(a);
_temp.appendLiteral(" bar");
auto b = _temp.toString();

I think Walter's point is that swift is still appending strings and then returning that. This requires allocations, and is not as preferable as directly processing the data. Not only that, but it's generating temporary strings just to add them to the larger thing that will be printed (I'm assuming this is not just a big string but an array/list, due to the beginning of the video and s1+s2+s3+s4).

I'd much prefer for example, printing using DIP1027 than constructing a string (even if the memory is reasonably fast, like malloc) just to throw it away.

I watched a lot of that video, it didn't impress me much. I use swift interpolation strings quite a bit, and they are useful. But I think D's will be much more performant and more straightforward for hooking (if they ever get in).

-Steve
              • ... Nicholas Wilson via Digitalmars-d-announce
              • ... Walter Bright via Digitalmars-d-announce
              • ... Arine via Digitalmars-d-announce
              • ... Arine via Digitalmars-d-announce
              • ... Adam D. Ruppe via Digitalmars-d-announce
              • ... Arine via Digitalmars-d-announce
              • ... Walter Bright via Digitalmars-d-announce
              • ... aliak via Digitalmars-d-announce
              • ... Walter Bright via Digitalmars-d-announce
              • ... Jacob Carlborg via Digitalmars-d-announce
              • ... Steven Schveighoffer via Digitalmars-d-announce
              • ... aliak via Digitalmars-d-announce
              • ... Adam D. Ruppe via Digitalmars-d-announce
              • ... Steven Schveighoffer via Digitalmars-d-announce
              • ... aliak via Digitalmars-d-announce
              • ... Adam D. Ruppe via Digitalmars-d-announce
              • ... Arine via Digitalmars-d-announce
              • ... Meta via Digitalmars-d-announce
  • Re: DIP 1027---String Inte... Robert M. Münch via Digitalmars-d-announce

Reply via email to