Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Neia Neutuladh via Digitalmars-d-learn
On Thursday, 21 December 2017 at 18:20:19 UTC, H. S. Teoh wrote: Even calling GC.collect directly did not guarantee the DB handle was closed at the right time. This may have been a bug in my code that left dangling references to it, or perhaps the array of Database handles was still scanned

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread bauss via Digitalmars-d-learn
On Thursday, 21 December 2017 at 19:43:16 UTC, Steven Schveighoffer wrote: On 12/20/17 9:57 PM, Mike Franklin wrote: [...] It's implementation defined :) The gist is, you cannot expect that destructors will be run in a timely manner, or at all. They may be called, and most of the time

Re: can't run libuid examples

2017-12-21 Thread bauss via Digitalmars-d-learn
On Thursday, 21 December 2017 at 18:41:28 UTC, greatsam4sure wrote: I am having problem with running the examples of libuid on Windows and how to use libuid on a project without errors. I am using dmd version 2.076 Okay, but how are we supposed to help if you don't show us what errors you

Re: Version Cygwin

2017-12-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/12/2017 4:22 PM, Anonymouse wrote: Cygwin is a reserved version[1], alongside Windows and linux and the like. However it doesn't seem to be automatically recognised. import std.stdio; void main() {     version(Cygwin) writeln("Cygwin"); } Compiled from a Cygwin prompt this prints

Re: Fold in Parallelism

2017-12-21 Thread Vino via Digitalmars-d-learn
On Friday, 22 December 2017 at 00:18:40 UTC, Seb wrote: On Friday, 22 December 2017 at 00:12:45 UTC, Vino wrote: On Thursday, 21 December 2017 at 06:31:52 UTC, Ali Çehreli wrote: [...] Hi Ali, Thank you very much, the pull request is in open state, so can you please let me know when can we

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 December 2017 at 00:09:31 UTC, Mike Franklin wrote: What condition(s) would cause a destructor for an object that is managed by the GC to potentially not be called? Here: === import std.stdio; class Clazz { ~this() { writeln("Class dest"); } } void

Re: Fold in Parallelism

2017-12-21 Thread Seb via Digitalmars-d-learn
On Friday, 22 December 2017 at 00:12:45 UTC, Vino wrote: On Thursday, 21 December 2017 at 06:31:52 UTC, Ali Çehreli wrote: On 12/19/2017 02:32 AM, Vino wrote: > even though it is a simple code copy+paste The change was a little more complicated than my naive adaptation from

Re: Fold in Parallelism

2017-12-21 Thread Vino via Digitalmars-d-learn
On Thursday, 21 December 2017 at 06:31:52 UTC, Ali Çehreli wrote: On 12/19/2017 02:32 AM, Vino wrote: > even though it is a simple code copy+paste The change was a little more complicated than my naive adaptation from std.algorithm.fold. Here is the pull request:

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Mike Franklin via Digitalmars-d-learn
On Thursday, 21 December 2017 at 19:43:16 UTC, Steven Schveighoffer wrote: The gist is, you cannot expect that destructors will be run in a timely manner, or at all. They may be called, and most of the time they are. But the language nor the current implementation makes a guarantee that

Re: No of threads

2017-12-21 Thread Vino via Digitalmars-d-learn
On Thursday, 21 December 2017 at 00:32:50 UTC, codephantom wrote: On Wednesday, 20 December 2017 at 13:41:06 UTC, Vino wrote: Hi Ali, Thank you very much, below are the observations, our program is used to calculate the size of the folders, and we don't see any improvements in the

Re: No of threads

2017-12-21 Thread Vino via Digitalmars-d-learn
On Wednesday, 20 December 2017 at 17:31:20 UTC, Ali Çehreli wrote: On 12/20/2017 05:41 AM, Vino wrote: > auto TL = dFiles.length; > auto TP = new TaskPool(TL); I assume dFiles is large. So, that's a lot of threads there. > foreach (d; TP.parallel(dFiles[],1)) You tried with larger work unit

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 December 2017 at 18:48:38 UTC, H. S. Teoh wrote: Alas, RefCounted doesn't work well with inheritance... Oh? What's the issue? Implicit casts don't work so you can't pass a RefCounted!Class as RefCounted!Interface except in simple cases using alias this tricks.

Re: One liner for creating an array filled by a factory method

2017-12-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/21/17 4:00 PM, kerdemdemir wrote: I have a case like : http://rextester.com/NFS28102 I have a factory method, I am creating some instances given some enums. My question is about : void PushIntoVector( BaseEnum[] baseEnumList ) {     Base[] baseList;     foreach ( tempEnum;

One liner for creating an array filled by a factory method

2017-12-21 Thread kerdemdemir via Digitalmars-d-learn
I have a case like : http://rextester.com/NFS28102 I have a factory method, I am creating some instances given some enums. My question is about : void PushIntoVector( BaseEnum[] baseEnumList ) { Base[] baseList; foreach ( tempEnum; baseEnumList ) { baseList ~=

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/20/17 9:57 PM, Mike Franklin wrote: "Don't expect class destructors to be called at all by the GC" I was a bit shocked to read that here: https://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors The document tries to clarify with: "The garbage collector is not guaranteed to

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 21, 2017 at 06:45:27PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Thursday, 21 December 2017 at 18:20:19 UTC, H. S. Teoh wrote: > > When the scoped destruction of structs isn't an option, RefCounted!T > > seems to be a less evil alternative than an unreliable class dtor.

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 December 2017 at 18:20:19 UTC, H. S. Teoh wrote: When the scoped destruction of structs isn't an option, RefCounted!T seems to be a less evil alternative than an unreliable class dtor. :-/ Alas, RefCounted doesn't work well with inheritance... Though, what you could do is

can't run libuid examples

2017-12-21 Thread greatsam4sure via Digitalmars-d-learn
I am having problem with running the examples of libuid on Windows and how to use libuid on a project without errors. I am using dmd version 2.076

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 21, 2017 at 06:50:44AM +, Mike Parker via Digitalmars-d-learn wrote: [...] > I just don't even bother with class destructors. Without a guarantee > that they can run and without any sort of deterministic behavior, it's > really not appropriate to refer to them as destructors and

Re: GUI program on Mac OS in D?

2017-12-21 Thread mrphobby via Digitalmars-d-learn
On Thursday, 21 December 2017 at 15:45:32 UTC, Adam D. Ruppe wrote: oh sorry i forgot to post this sooner here's my code so far. when i'm reasonably happy with it, it will be part of my simpledisplay.d. I might leave it undocumented, but if you wanted to dive into my source the final version

Re: It's possible to declare a variable inside a static foreach()?

2017-12-21 Thread Seb via Digitalmars-d-learn
On Thursday, 21 December 2017 at 16:38:36 UTC, Anonymouse wrote: On Thursday, 21 December 2017 at 16:25:00 UTC, Marc wrote: For example, I'd like to declare a variable inside a static foreach like in below code, just for better organization, otherwise, I have to use the value directly instead

Re: It's possible to declare a variable inside a static foreach()?

2017-12-21 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 21 December 2017 at 16:25:00 UTC, Marc wrote: For example, I'd like to declare a variable inside a static foreach like in below code, just for better organization, otherwise, I have to use the value directly instead of the variable. If the value is used more than once, it might be

It's possible to declare a variable inside a static foreach()?

2017-12-21 Thread Marc via Digitalmars-d-learn
For example, I'd like to declare a variable inside a static foreach like in below code, just for better organization, otherwise, I have to use the value directly instead of the variable. If the value is used more than once, it might be inviable. enum allMembers =

Version Cygwin

2017-12-21 Thread Anonymouse via Digitalmars-d-learn
Cygwin is a reserved version[1], alongside Windows and linux and the like. However it doesn't seem to be automatically recognised. import std.stdio; void main() { version(Cygwin) writeln("Cygwin"); } Compiled from a Cygwin prompt this prints nothing. So I thought to add versions: [

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread 12345swordy via Digitalmars-d-learn
On Thursday, 21 December 2017 at 06:50:44 UTC, Mike Parker wrote: On Thursday, 21 December 2017 at 04:10:56 UTC, user1234 wrote: [...] [...] [...] The root of the problem is that in D, class destruction and finalization are conflated. It would be much more accurate to refer to ~this

Re: std way to remove multiple indices from an array at once

2017-12-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/20/17 7:52 PM, Nicholas Wilson wrote: On Thursday, 21 December 2017 at 00:23:08 UTC, Steven Schveighoffer wrote: On 12/20/17 6:01 PM, aliak wrote: Hi, is there a way to remove a number of elements from an array by a range of indices in the standard library somewhere? I wrote one (code

Re: GUI program on Mac OS in D?

2017-12-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 14 December 2017 at 19:10:26 UTC, mrphobby wrote: This looks pretty awesome and very much like something I was looking for. Would really appreciate if you could share your work. Otherwise I'll have to roll up my sleeves and try hacking it on my own :) oh sorry i forgot to post

Re: Write native GUI applications for Windows

2017-12-21 Thread FrankLike via Digitalmars-d-learn
On Monday, 18 December 2017 at 07:55:25 UTC, Andrey wrote: Hello! I have a question about creating native GUI applications for Windows 7 or/and Windows 10. Hi,here is a very good native d gui lib,it's name is "dgui": https://github.com/FrankLIKE/DguiT/ I fork and modify ,let it work on

Re: GUI program on Mac OS in D?

2017-12-21 Thread mrphobby via Digitalmars-d-learn
On Thursday, 14 December 2017 at 19:10:26 UTC, mrphobby wrote: On Thursday, 14 December 2017 at 14:07:25 UTC, Adam D. Ruppe wrote: I was playing with this myself based on Jacob's code and made it look like this: extern (Objective-C) interface ViewController : NSViewController {

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 21 December 2017 at 14:26:55 UTC, Guillaume Piolat wrote: On Thursday, 21 December 2017 at 06:50:44 UTC, Mike Parker wrote: That's what I've taken to doing manually, by implementing a `terminate` function in my classes that I either call directly or via a ref-counted templated

Re: Don't expect class destructors to be called at all by the GC

2017-12-21 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 21 December 2017 at 06:50:44 UTC, Mike Parker wrote: That's what I've taken to doing manually, by implementing a `terminate` function in my classes that I either call directly or via a ref-counted templated struct called Terminator. I feel like I'm rambling but.. The problem with

Re: std way to remove multiple indices from an array at once

2017-12-21 Thread aliak via Digitalmars-d-learn
On Thursday, 21 December 2017 at 00:52:29 UTC, Nicholas Wilson wrote: On Thursday, 21 December 2017 at 00:23:08 UTC, Steven Schveighoffer wrote: I'm assuming here indices is sorted? Because it appears you expect that in your code. However, I'm going to assume it isn't sorted at first. auto

Re: How to pack a struct to a ubyte[] in a more "The D way" style ?

2017-12-21 Thread Binghoo Dang via Digitalmars-d-learn
hi Davis, Thanks for your great help to me! Yeah, the library may had a design principle when it was designed, as you can see the buffer appender is not that suitable for an application-defined structured data packing. And after I turn to the bitfield, I then got another trouble: The

Re: A DUB Case Study: Compiling DMD as a Library

2017-12-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-21 05:12, Venkat wrote: I did a fresh clone of dmd and added that as a dependency. That fixed it. Should've thought of it !! Thankyou. Great that it works :) -- /Jacob Carlborg

Re: How to pack a struct to a ubyte[] in a more "The D way" style ?

2017-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 18, 2017 08:45:32 Binghoo Dang via Digitalmars-d-learn wrote: > hi Davis, > > I read the std.bitmanip, and I tried to test the code like below: > > ``` > import std.stdio; > import std.array; > import std.bitmanip; > void main(string[] args) > { > align(1) struct c { >

Re: How to pack a struct to a ubyte[] in a more "The D way" style ?

2017-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 18, 2017 05:32:02 Binghoo Dang via Digitalmars-d-learn wrote: > Thanks for your idea. > > On Monday, 18 December 2017 at 05:08:24 UTC, Jonathan M Davis > > wrote: > >> ubyte[] makeCMDPacket(RCPCmd cmd, in ubyte[] data) > >> { > >> > >>

Re: GC in D and synadard library.

2017-12-21 Thread Mike Franklin via Digitalmars-d-learn
On Thursday, 21 December 2017 at 10:49:46 UTC, Dan Partelly wrote: I started to look into D very recently. I would like to know the following, if you guys are so nice to help me: 1. What is the performance of D's GC, what trade-offs where done in design , and if a in-deep primer on

Re: GC in D and synadard library.

2017-12-21 Thread Seb via Digitalmars-d-learn
On Thursday, 21 December 2017 at 10:49:46 UTC, Dan Partelly wrote: I started to look into D very recently. I would like to know the following, if you guys are so nice to help me: 1. What is the performance of D's GC, what trade-offs where done in design , and if a in-deep primer on

Re: GC in D and synadard library.

2017-12-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/12/2017 10:49 AM, Dan Partelly wrote: I started to look into D very recently. I would like to know the following, if you guys are so nice to help me: 1. What is the performance of D's GC, what trade-offs where done in design , and if a in-deep primer on efficient usage and gotchas of

GC in D and synadard library.

2017-12-21 Thread Dan Partelly via Digitalmars-d-learn
I started to look into D very recently. I would like to know the following, if you guys are so nice to help me: 1. What is the performance of D's GC, what trade-offs where done in design , and if a in-deep primer on efficient usage and gotchas of the current implementation exists. 2. GC

Re: WARN on implicit super?

2017-12-21 Thread bauss via Digitalmars-d-learn
On Thursday, 21 December 2017 at 06:47:25 UTC, Ali Çehreli wrote: On 12/20/2017 10:36 PM, Chris Katko wrote: Is there any way to get a warning anytime an implicit super constructor is called in a sub-class/child-class? There can be a number of solutions but can you please demonstrate the

Re: Fold in Parallelism

2017-12-21 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2017-12-20 at 22:31 -0800, Ali Çehreli via Digitalmars-d-learn wrote: > On 12/19/2017 02:32 AM, Vino wrote: > > > even though it is a simple code copy+paste > > The change was a little more complicated than my naive adaptation > from > std.algorithm.fold. Here is the pull request: > >

Re: Behavior of joining mapresults

2017-12-21 Thread Christian Köstlin via Digitalmars-d-learn
On 21.12.17 08:41, Jonathan M Davis wrote: > I would think that it would make a lot more sense to simply put the whole > thing in an array than to use memoize. e.g. > > auto arr = iota(1, 5).map!parse().array(); thats also possible, but i wanted to make use of the laziness ... e.g. if i then