On Sunday, 8 April 2018 at 15:04:49 UTC, number wrote:
the write() shows a 'null' if the struct has a function/method.
why is that?
writeln(s); // S(0)
writeln(typeid(s).sizeof); // 8
import std.conv: to;
writeln(s2); // S2(0, null)
writeln(typeid(s2).sizeof); // 8
S2 is a nested struct , which means it has a hidden pointer
field that's used to access its enclosing scope. If you change
the definition to `static struct S2`, you'll get the same output
for both structs.