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

It's a bad pattern in any language because it exposes too much details of storage layout and violates encapsulation. You probably don't want to expose internal implementation details in your API unless such exposure is critical to performance, and if it is critical to performance it seems unlikely that you'd be writing it in anything other than C++ anyway.


This seems orthogonal to internal implementation hiding, especially if the "API" is not a public library API, say, but an internal one.

Then again, contracts about who can modify what data are also part of any public API; historically, there have been plenty of (quite decent) APIs that have returned pointers to internal structures that have limited lifetimes, in languages like C that don't enforce lifetimes at all.




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

Search: