{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiak7532eljrgol7uicq7otgt5cyfcoetmrvuzpz4m5vlgyyqunxji",
"uri": "at://did:plc:i7budt2wflrcfy6jtvfocbix/app.bsky.feed.post/3mfxs3z3dj7i2"
},
"path": "/viewtopic.php?p=1278325#p1278325",
"publishedAt": "2026-02-28T23:17:02.000Z",
"site": "https://www.tt-forums.net",
"tags": [
"GoldMine"
],
"textContent": "> Making deep copies is not a straightforward problem, mostly because a generic copy-making algorithm does not know whether a given field of a complex data structure is to be copied or not.\n\nThank you for jumping in,\nthe interpreter or compiler shouldn't need to know, it should provide API to let programmer choose what they need.\n\nFor instance there is AIList.AddList which is fine to copy by reference, but why isn't there AIList.CopyList?\n\n\n> That is done for the sake of efficiency and simplicity. Efficiency - because data is not copied needlessly. Simplicity - because distinguishing 'values' and 'references' leads to pointers, moves, copy/move/reference assignments, and a plethora of other low-level problems. At this point, you might just throw away any semblance of 'scripting' and run an interpreted C, because that is what you are demanding.\n\nHere is example:\nYou have a list which you need to iterate and remove elements from it.\nBut you can't remove elements while iterating.\n\nSo what you do is make a copy, iterate the copy and remove items from original.\nBut since you can't make a copy now what? how do you iterate and remove elements?\n\nI didn't test what happens but it anyway works to iterate a copy and remove from original, not sure yet why it works, but I observed strange things happening but didn't have time to debug.\n\nBut that was not reason why I needed a copy, I needed a copy to split AIList into multiple equal length chunks.\nThe way this is done is by using modulo within for loop to break and clear temporary container and copying it to destination, however since copy is by reference the resulting chunks will now contain all same values (the most recent ones), so no way to split the container.\n\n\n> You will need to make a deep copy of the container you want a copy from, assuming you truly, actually, really want a copy.\n\nSo far I didn't need a true copy except this one justified time, but array.extend works fine to have a copy, but it's not just 1 line to achieve this, what a waste of ticks.\n\nStatistics: Posted by GoldMine — 28 Feb 2026 23:17\n\n* * *",
"title": "OpenTTD AIs and Game Scripts • Re: nasal demons in action",
"updatedAt": "2026-02-28T23:17:02.000Z"
}