How to read this signature? (writeTo in DIP9)

bearophile bearophileHUGS at lycos.com
Fri Nov 19 11:43:03 PST 2010


Graham Fawcett:

> void writeTo(scope delegate(in char[] data) sink, 
> 	     string format = null) const
> 
> // from http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9
> 
> Particularly, how does "scope" modify the delegate, and what is the
> meaning of the trailing "const"?

"scope" means that the sink delegate is not a true closure, its outer scope is never allocated on the heap. "const" member functions means that inside it the "this" is const, so writeTo() can't modify the class/struct attributes.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list