On 01.07.2024 13:31, ryuukk_ wrote:
On Monday, 1 July 2024 at 10:20:25 UTC, drug007 wrote:
No problem, make a full string then mixin it.
Your "no problem" = lot of string concatenation therefore slower and
memory hungry, i have no desire to do that
Do you think that string concatenation is the most heavy operation on
using string mixin?
When you pass the mixin string to the compiler it allocates memory too.
If you want to use incomplete mixin strings the compiler will accumulate
it (allocating additional memory) until it builds a complete AST node to
mix in at once. At best, it will cost the same as building a full string
as I suggested but in general it may cost even more. Also, compilation
would take longer because the compiler would need to have additional
logic to detect the end of your string mixin etc. Your profit from
avoiding string concatenation would almost negative.