D-Programming-Language/phobos — pull request #1294 by someboddy (2013-05-18 16:57:19+00:00)
Title: Add the std.idioms module - a common idioms library.

Here is the forum discussion about this module suggestion: http://forum.dlang.org/thread/fofbrlqruxbevnxchxdp@forum.dlang.org

Currently 3 idioms are implemented:

* Properties - Generate property getter and setter accessors
for member fields.
* LowLockSingleton - Turns the class into a singleon, using David
Simcha's and Alexander Terekhov's low lock
singleton implementation approach.
* ThreadLocalSingleton - Turns the class into a thread local singleton.

#### `Properties` usage:
```D
class Foo
{
mixin Properties!q{
@Asserting("a < 10") int x;
@Enforcing("a <= x") int y;
};
}
```
This will create in the class `Foo` two property fields - `x` and `y`, where `x`'s setter will `assert` that any new value is smaller than `10`, and `y`'s setter will check that any new value is smaller or equal to the current value of `x` and throw a `PropertyException` otherwise.

#### `LowLockSingleton` and `ThreadLocalSingleton` usage:
```D
class Foo
{
mixin LowLockSingleton;
}
class Bar
{
mixin ThreadLocalSingleton;
}
```
This will turn `Foo` into a global singleton(all threads access the same instance) and `Bar` into a thread local singleton(each thread will have it's own instance).