Re: Avoiding GC in D and code consistancy

2017-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/17 7:50 AM, Steven Schveighoffer wrote: Note, you can use a "sink" version of toString as well, and avoid the gc: void toString(void delegate(const(char)[]) sink) @nogc {     // use formatValue to push into the sink } I guess I'm missing some parameters here, go with what Seb

Re: Avoiding GC in D and code consistancy

2017-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/17 6:16 AM, Tim Hsu wrote: On Sunday, 31 December 2017 at 07:32:50 UTC, Ali Çehreli wrote: On 12/30/2017 11:16 PM, Tim Hsu wrote: > Struct version of Vector3f can't derive toString > method. writeln() prints unformated struct members. I know I can use > helper function here. But is

Re: Avoiding GC in D and code consistancy

2017-12-31 Thread Seb via Digitalmars-d-learn
On Sunday, 31 December 2017 at 07:16:46 UTC, Tim Hsu wrote: I came from C++ looking forward to D. Some languages require programmers to use GC all the time. However, A lot of time we don't really need GC especially when the time of destruction is deterministic in compile time. [...] You

Re: Avoiding GC in D and code consistancy

2017-12-31 Thread Tim Hsu via Digitalmars-d-learn
On Sunday, 31 December 2017 at 07:32:50 UTC, Ali Çehreli wrote: On 12/30/2017 11:16 PM, Tim Hsu wrote: > Struct version of Vector3f can't derive toString > method. writeln() prints unformated struct members. I know I can use > helper function here. But is there any other way? The normal way

Re: Avoiding GC in D and code consistancy

2017-12-30 Thread Ali Çehreli via Digitalmars-d-learn
On 12/30/2017 11:16 PM, Tim Hsu wrote: > Struct version of Vector3f can't derive toString > method. writeln() prints unformated struct members. I know I can use > helper function here. But is there any other way? The normal way that I know is to insert a function like the following into

Avoiding GC in D and code consistancy

2017-12-30 Thread Tim Hsu via Digitalmars-d-learn
I came from C++ looking forward to D. Some languages require programmers to use GC all the time. However, A lot of time we don't really need GC especially when the time of destruction is deterministic in compile time. I found that struct in D is allocate on stack by default. And we can use