p0nce / d-idioms

"Effective D" without the haircut.
http://p0nce.github.io/d-idioms/
82 stars 17 forks source link

Fiw static article #133

Open p0nce opened 7 years ago

p0nce commented 7 years ago
<calex> p0nce: I just read the rest of your "four ways to use static" tip. You missed one of the more nifty usages D retained from C++: function-local static variables.
<calex> size_t monotonic() { static size_t sequenceNumber; return sequenceNumber++; }
<calex> assert( monotonic != monotonic );
<ketmar> p0nce: also, `__gshared` implies `static` everywhere except top-level declarations