porton
porton

Reputation: 5801

What are scope functions in Dlang?

From https://github.com/MartinNowak/io/blob/master/src/std/io/package.d:

size_t write(const scope ubyte[] buf) scope;

What is the meaning of the second scope keyword?

Upvotes: 2

Views: 192

Answers (1)

Adam D. Ruppe
Adam D. Ruppe

Reputation: 25595

It applies the scope qualifier to the hidden this parameter.

Generally speaking, any keyword after the function applies to this, but otherwise has the same result as if it was on any other parameter. For example, a const at the end means the this reference is const.

Upvotes: 4

Related Questions