Hacker News new | ask | show | jobs
by skybrian 1748 days ago
There are conventions that help, but they could be made explicit:

- If you don't know where a slice came from (such as getting it passed as an argument), treat it as read-only. Any exceptions should be documented.

- If you're going to mutate a slice, make it a private member of a struct and don't give out direct access to it.