GOLF(2gg)
π GOLF(2gg) β delete-string π
okay so bestie, we're in the Golf manual, section 2gg, and today's main character is delete-string. yes she's from Development, and yes she eats. let's get into it β¨
πΈ NAME πΈ
delete-string β (strings) π
π¦ PURPOSE π¦
Free string memory. that's it, that's the job, she's a memory liberator π
β¨ SYNTAX β¨
delete-string <string>
π DESCRIPTION π
delete-string frees the <string> variable that was previously allocated by a Golf statement. freeing your girl, setting her free, the whole vibe ποΈ
ngl though β freeing memory is in most cases unnecessary, because Golf will automatically do it for you at the end of each request. so if you're reaching for delete-string, you should have a good reason, fr fr. otherwise it's giving "doing extra homework for no reason" π
here's the tea on how Golf actually tracks this: Golf keeps count of <string> references for process-scoped memory (go peek at memory-handling for that whole situation). and that kind of memory gets deleted at the end of the request, once the reference count reaches zero. slay, automatic cleanup, we love to see it π
now for non-process-scoped memory, it's a lil different. if <string> is referenced by other variables, then <string> may not be deleted. she's held, she's claimed, she's not going anywhere. but β and this is the important part β regardless of whether the memory referenced by <string> is actually deleted or not, <string> becomes an empty string ("") after delete-string. so the variable itself is always emptied out, no cap. periodt π
β οΈ heads up bestie: don't just sprinkle delete-string around for fun. Golf handles it for you at the end of each request, so only call it when you've got a real reason. otherwise you're just doing cardio for nothing πβοΈ
π EXAMPLES π
Allocate and free a random string β look how cute this is:
random-string to ran_str
...
delete-string ran_str
Free a string allocated by write-string (this one's made of 100 "Hello World"s, obsessed):
write-string ws
start-loop repeat 100
@Hello World
end-loop
end-write-string
...
delete-string ws
π SEE ALSO π
Strings
concatenate-strings copy-string count-substring delete-string lower-string new-string read-split replace-string set-string split-string string-length trim-string upper-string write-string β See all documentation β¨
and that's the whole page, bestie π«Ά go free some strings (responsibly, or honestly just let Golf do it). this was $VERSION, dated $DATE, and yes this is still GOLF(2gg) β mwah ππ§β
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms