Consider:
class B
{
public:
int i = 4;
}
class A
{
public:
B b;
this()
{
b = new B;
}
ref B f()
{
return b;
}
}
The ref storage class in front of member function f is redundant right? Class objects are always passed by reference, so returning B and ref B is equivalent?
Second: pure member functions? A pure function is to return only something that depends on the arguments. It should thus not depends on any data members of the class, since they might change the output of the function even for the same arguments passed in. So a pure member function is consequently also a static member function? (the reverse might not be true)
Third: what is the difference between a const and an immutable member class? To differentiate between member function calls of immutable and const class objects? Semantically it is equal in that we can't change data members with both attributes, right?
Fourth: should I add as many function attributes as possible? Like pure, const or immutable, nothrow and final?
Awesome, just discovered this works:
inout(B) f() inout
{
return b;
}