Re: toString contains null for struct with function/method

2018-04-09 Thread number via Digitalmars-d-learn
On Sunday, 8 April 2018 at 15:51:05 UTC, Paul Backus wrote: On Sunday, 8 April 2018 at 15:04:49 UTC, number wrote: writeln(s2);// S2(0, null) S2 is a nested struct [1], which means it has a hidden pointer field that's used to access its enclosing scope. If you change

Re: toString contains null for struct with function/method

2018-04-08 Thread Paul Backus via Digitalmars-d-learn
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? ``` import std.stdio; void main() { struct S { int i; } S s; writeln(s);// S(0)

toString contains null for struct with function/method

2018-04-08 Thread number via Digitalmars-d-learn
the write() shows a 'null' if the struct has a function/method. why is that? ``` import std.stdio; void main() { struct S { int i; } S s; writeln(s);// S(0) writeln(typeid(s).sizeof); // 8 struct S2