Do non-member functions improve encapsulation in D?
Artur Skawina via Digitalmars-d
digitalmars-d at puremagic.com
Mon Apr 21 09:35:10 PDT 2014
On 04/21/14 14:45, Steven Schveighoffer via Digitalmars-d wrote:
> Reasons off the top of my head not to make them module functions:
[...]
Functions, unlike methods, do not work with rvalues.
Ie
struct S {
long[999999] data;
auto f() { return data[0]; }
}
auto g(ref S _this) { with (_this) return data[1]; }
void main() {
auto a = S().f();
auto b = S().g();
}
artur
More information about the Digitalmars-d
mailing list