On Sunday, 29 December 2013 at 21:47:52 UTC, Namespace wrote:
On Sunday, 29 December 2013 at 19:42:39 UTC, Jonathan wrote:
If I want to write a function that operates on a struct
struct S { }
What are the differences between:
void(S* s)
void(ref S s)
You cannot set a default value (like null) for ref parameters,
but you can for pointer.
Well, a ref *can't* be null. In terms of default value, both can
have them, in terms of referencing a static object though.
The only functional difference I know of in pass-by-ref vs
pass-by-pointer is indeed the null pointer:
- Pass by pointer means you *can* pass a null (yay).
- But pass by ref means the implementation does not have to worry
about null references (yay).