Hacker News new | past | comments | ask | show | jobs | submit login

Returning value types by value (structures) is a compiler bug? C++ and D both try to be binary-compatible with C, they MUST return a structure by copying it. An excellent article, but this little example was weird.

I haven't done any serious development in D, but I absolutely agree with his complaints about Walter's leadership, he needs to loosen up a little and let it go: I haven't checked if he changed his mind, but it used to be a case where you couldn't just host binaries of D compiler on your site, they had to be downloaded from Digital Mars page in a form of two confusing ZIP files with two intersecting directory trees.




"C++ and D both try to be binary-compatible with C, they MUST return a structure by copying it."

Only for code that has C linkage. For normal C++ or D code the calling convention can be whatever the compiler wants, it's not restricted by the C calling convention.

(C linkage is specified in C++ with 'extern "C"', and with 'extern (C)' in D.)




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

Search: