5 ms·
> All the listed weaknesses also have benefits. For instance it is easy to get a substring without need to copy. To make substring in some other languages, you
by v_lisivka 7y ago
> All the listed weaknesses also have benefits. For instance it is easy to get a substring without need to copy.
To make substring in some other languages, you need to store pointer to beginning of the substring and length of substring.
To make substring in C, you need to store pointer to beginning of the substring and put '\0' into original string.
- johannes1234321 7y ago> To make substring in some other languages, you need to store pointer to beginning of the substring and length of substring. Plus a pointer to the beginning, plus a reference counter as the user expects it to manage lifetime. In C this is the user's job. Where they know the life time is guaranteed they can optimize.
- Nursie 7y agoI coded in C for over a decade. Never did I need a reference counter.
- jstimpfle 7y agoNo, you store offset + length.