Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Delphi uses a pointer to the latter, in addition to keeping the actual strings with a zero at the end. That way a cast to a C-style "string" is free.

In order to allow for the pointer to live on stack and minimize copying, the data is also reference counted and the compiler takes care of inserting the necessary reference counting calls where needed.

Overall it's pretty flexible, but the reference counting means it's not ideal to use shared strings in heavily threaded code. Of course the second a thread modifies a string, a new string is allocated and that thread can happily work on its "own" string.

Anyway, just yet another way of implementing strings.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: