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

Whether you copy or pass by reference has everything to do with the language semantcis, ABI and calling convention and nothing to do with asm.

For example, if you look at the generated asm, C on amd64 will happily pass a struct by copy in registers, but will pass an array by address.

The designers of C decided to give arrays pass by reference semantics and struct pass by value [1]; this was done because is convenient: you often want to iterate through arrays and pointers are the most generic way, but it does make arrays not first class.

[1] admittedly traditional C couldn't pass structs at all.



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

Search: