The only thing I can think of: struct Once(T) { this(T val) { i = val; }
immutable T i; alias i this; } void main() { Once!int i = 1; // ok i = 4; // ng } However it seems I've found a little hole in the system: void foo(ref int x) { x = 2; } void main() { Once!int i = 1; // ok foo(i); assert(i == 1); // fail, changed to 2 } Is this reported somewhere?