ref type versus ptr type on input

John Colvin john.loughran.colvin at gmail.com
Sun Dec 29 12:00:25 PST 2013


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)

s is a pointer to an instance of S, in the raw C sense.

> void(ref S s)

s can be used as a normal S, but changes are visible to the 
caller. It can be imagined as a pointer behind the scenes.

>
> Also, for my general knowledge, is there a way to set default 
> function parameters, such as scope or lazy?

I don't fully understand what you mean by this.


More information about the Digitalmars-d-learn mailing list