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
ary(). scoped! > won't work here. > > Is there a better to write vector3f class while avoiding GC? Yeah, it doesn't make sense that a type of x, y, z should be a class. I would stay with a struct here. Sorry I am a bit disappointed. It seems writeln itself will check if the st

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
re. > > Is there a better to write vector3f class while avoiding GC? Yeah, it doesn't make sense that a type of x, y, z should be a class. I would stay with a struct here. Ali Sorry I am a bit disappointed. It seems writeln itself will check if the struct to be printed has toString. If not, it use default struct printer.

Re: Avoiding GC in D and code consistancy

2017-12-30 Thread Ali Çehreli via Digitalmars-d-learn
following into Vector3f: string toString() { import std.string : format; return format("%s,%s,%s", x, y, z); } > class version of Vector3f. Require new operator in opBinary(). scoped! > won't work here. > > Is there a better to write vector3f class while avoi

Avoiding GC in D and code consistancy

2017-12-30 Thread Tim Hsu via Digitalmars-d-learn
ctor3f. Require new operator in opBinary(). scoped! won't work here. Is there a better to write vector3f class while avoiding GC?

Re: Avoiding GC

2016-10-28 Thread Guillaume Piolat via Digitalmars-d-learn
On Friday, 28 October 2016 at 11:50:20 UTC, hardreset wrote: On Thursday, 27 October 2016 at 07:52:09 UTC, Guillaume Piolat wrote: On Wednesday, 26 October 2016 at 08:18:07 UTC, hardreset wrote: Is there a page somewhere on how to program D without using the GC? The information is scattered.

Re: Avoiding GC

2016-10-28 Thread hardreset via Digitalmars-d-learn
On Thursday, 27 October 2016 at 07:52:09 UTC, Guillaume Piolat wrote: On Wednesday, 26 October 2016 at 08:18:07 UTC, hardreset wrote: Is there a page somewhere on how to program D without using the GC? The information is scattered. How do I allocate / free structs / classes on the heap

Re: Avoiding GC

2016-10-27 Thread Guillaume Piolat via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 08:18:07 UTC, hardreset wrote: Is there a page somewhere on how to program D without using the GC? The information is scattered. How do I allocate / free structs / classes on the heap manually? Classes =>

Re: Avoiding GC

2016-10-26 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 08:18:07 UTC, hardreset wrote: Is there a page somewhere on how to program D without using the GC? How do I allocate / free structs / classes on the heap manually? New would be GCed memeory wouldnt it? Delete is being depreciated? thanks. There is the

Re: Avoiding GC

2016-10-26 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 08:18:07 UTC, hardreset wrote: Is there a page somewhere on how to program D without using the GC? How do I allocate / free structs / classes on the heap manually? New would be GCed memeory wouldnt it? Delete is being depreciated? thanks. Probably you want

Avoiding GC

2016-10-26 Thread hardreset via Digitalmars-d-learn
Is there a page somewhere on how to program D without using the GC? How do I allocate / free structs / classes on the heap manually? New would be GCed memeory wouldnt it? Delete is being depreciated? thanks.

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread Kagamin via Digitalmars-d-learn
Whether s.front uses GC is determined by s.front implementation, caller can't affect it.

Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread via Digitalmars-d-learn
When reading/parsing data from disk often try to write code such as foreach (const line; File(filePath).byLine) { auto s = line.splitter( ) const x = s.front.to!uint; s.popFront; const y = s.front.to!double; s.popFront; ... } In response to all the

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread via Digitalmars-d-learn
On Friday, 13 February 2015 at 09:13:48 UTC, Kagamin wrote: Whether s.front uses GC is determined by s.front implementation, caller can't affect it. I'm talking about internal changes to DMD, in this case.

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread Tobias Pankrath via Digitalmars-d-learn
On Friday, 13 February 2015 at 08:21:53 UTC, Per Nordlöw wrote: When reading/parsing data from disk often try to write code such as foreach (const line; File(filePath).byLine) { auto s = line.splitter( ) const x = s.front.to!uint; s.popFront; const y =

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread via Digitalmars-d-learn
On Friday, 13 February 2015 at 09:13:48 UTC, Kagamin wrote: Whether s.front uses GC is determined by s.front implementation, caller can't affect it. Compiling https://github.com/nordlow/justd/blob/master/t_splitter.d with -vgc on dmd git master gives no warnings about GC allocations! Is

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread Tobias Pankrath via Digitalmars-d-learn
On Friday, 13 February 2015 at 11:34:50 UTC, Per Nordlöw wrote: On Friday, 13 February 2015 at 09:13:48 UTC, Kagamin wrote: Whether s.front uses GC is determined by s.front implementation, caller can't affect it. Compiling https://github.com/nordlow/justd/blob/master/t_splitter.d with -vgc

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread via Digitalmars-d-learn
On Friday, 13 February 2015 at 13:07:04 UTC, bearophile wrote: I suggest you to read how a marksweep GC works, or better to implement a bare-bones marksweep GC in C language yourself for Lisp-like cons cells, you only need 100 lines of code or so to do it. Got it. Thanks.

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread via Digitalmars-d-learn
On Friday, 13 February 2015 at 12:50:14 UTC, Tobias Pankrath wrote: There are no reference counts involved, just simple arithmetic. string a = abc; string b = a[1 .. $]; Then how does the GC know when to release when there are multiple references? Is this because string references

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread Tobias Pankrath via Digitalmars-d-learn
On Friday, 13 February 2015 at 12:40:57 UTC, Per Nordlöw wrote: On Friday, 13 February 2015 at 11:52:50 UTC, Tobias Pankrath wrote: On Friday, 13 February 2015 at 11:34:50 UTC, Per Nordlöw wrote: On Friday, 13 February 2015 at 09:13:48 UTC, Kagamin wrote: Whether s.front uses GC is determined

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread bearophile via Digitalmars-d-learn
Per Nordlöw: Then how does the GC know when to release when there are multiple references? The mark phase counts what's reachable and what can't be reached. If an object has one pointer to it, or one hundred pointers, it is not removed. If nothing points to it, it is removed. I suggest

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread Tobias Pankrath via Digitalmars-d-learn
On Friday, 13 February 2015 at 12:58:40 UTC, Per Nordlöw wrote: On Friday, 13 February 2015 at 12:50:14 UTC, Tobias Pankrath wrote: There are no reference counts involved, just simple arithmetic. string a = abc; string b = a[1 .. $]; Then how does the GC know when to release when there are

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread bearophile via Digitalmars-d-learn
Tobias Pankrath: Why should splitter.front allocate? I think that front was able to throw Unicode exceptions, that require the GC. But I think later they have become asserts, that don't require the GC. Bye, bearophile

Re: Data-Flow (Escape) Analysis to Aid in Avoiding GC

2015-02-13 Thread via Digitalmars-d-learn
On Friday, 13 February 2015 at 11:52:50 UTC, Tobias Pankrath wrote: On Friday, 13 February 2015 at 11:34:50 UTC, Per Nordlöw wrote: On Friday, 13 February 2015 at 09:13:48 UTC, Kagamin wrote: Whether s.front uses GC is determined by s.front implementation, caller can't affect it. Compiling