Skip to content

Instantly share code, notes, and snippets.

@yshui
Created May 8, 2018 22:00
Show Gist options
  • Select an option

  • Save yshui/c6692ba1570c828ca35f57db170ed9ba to your computer and use it in GitHub Desktop.

Select an option

Save yshui/c6692ba1570c828ca35f57db170ed9ba to your computer and use it in GitHub Desktop.
Idea
//fun(T)(ref immutable T a){
// //If T is a struct, and I only use immutable fields of T
// //then it should be ok to call fun with a partially mutable type
//}
void f(T: class)(immutable T a) {
return a.x+1;
}
void main() {
class A {
immutable int x = 10;
double f;
}
auto x = new A;
f(x); // <- fine
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment