templates: {s} with one string hole and nothing else is a new string, not s itself - it was the one template that passed its string through (string() does), and code that wrote it as a copy kept what it then freed; the mark rides the callee, since escape analysis writes the call's uns; reseeded
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a436cfbe35
commit
dd25267502
6 changed files with 29922 additions and 29729 deletions
|
|
@ -2078,6 +2078,10 @@ let msg = `hello {name}, you have {count + 1} messages`
|
|||
so a string, a char or another template literal inside it is taken whole - `` `a {wrap(`b {n}`)} c` ``
|
||||
is one literal, and a brace or a backtick inside a string in a hole is text.
|
||||
|
||||
A template is always a new string. `` `{s}` `` - one string hole and nothing else - is a copy of
|
||||
`s`, not `s` itself (where `str(s)` passes a string through), so it can be kept after `s` is given
|
||||
back.
|
||||
|
||||
**Slicing.** `s[a..b]` is a fresh substring of the bytes `[a, b)`, and `len(s)`
|
||||
is a string's byte length — so `path[0..len(path) - 6]` trims an extension and
|
||||
`s[i]` still indexes a single byte. `expr with { field: … }`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue