Re: static array of structs clarification questions

2016-02-13 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 12 February 2016 at 21:56:09 UTC, Steven Schveighoffer wrote: That's odd. I think anonymous probably has the answer (they are context pointers), but I'm also surprised they are null, they shouldn't be. In this example, `void foo()` doesn't access any outer variables, so there's no

Index file for ddoc

2016-02-13 Thread tcak via Digitalmars-d-learn
Maybe I am missing, but I do not see any index file when html files are generated by ddoc. Is there any way to generate index file automatically, so, a tree like links will be listed all created documentation files? If the problem is about the possibility of having index.d and it would be con

How is the TypeInfo assigned?

2016-02-13 Thread Tofu Ninja via Digitalmars-d-learn
Is the TypeInfo given by typeid() guaranteed to be the same for a type regardless of where I call it? I guess my question is, is the TypeInfo a valid way to dynamically check types? I am implementing a message passing system for an entity-component system, I was planning to use structs as mes

Re: static array of structs clarification questions

2016-02-13 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 13 February 2016 at 10:22:36 UTC, Marc Schütz wrote: On Friday, 12 February 2016 at 21:56:09 UTC, Steven Schveighoffer wrote: That's odd. I think anonymous probably has the answer (they are context pointers), but I'm also surprised they are null, they shouldn't be. In this exampl

Re: Index file for ddoc

2016-02-13 Thread ZombineDev via Digitalmars-d-learn
On Saturday, 13 February 2016 at 11:28:40 UTC, tcak wrote: Maybe I am missing, but I do not see any index file when html files are generated by ddoc. Is there any way to generate index file automatically, so, a tree like links will be listed all created documentation files? If the problem is

Re: How is the TypeInfo assigned?

2016-02-13 Thread Benjamin Thaut via Digitalmars-d-learn
On Saturday, 13 February 2016 at 12:44:40 UTC, Tofu Ninja wrote: Is the TypeInfo given by typeid() guaranteed to be the same for a type regardless of where I call it? I guess my question is, is the TypeInfo a valid way to dynamically check types? I am implementing a message passing system for

Re: static array of structs clarification questions

2016-02-13 Thread Marc Schütz via Digitalmars-d-learn
On Saturday, 13 February 2016 at 14:53:39 UTC, ZombineDev wrote: On Saturday, 13 February 2016 at 10:22:36 UTC, Marc Schütz wrote: On Friday, 12 February 2016 at 21:56:09 UTC, Steven Schveighoffer wrote: That's odd. I think anonymous probably has the answer (they are context pointers), but I'm

Is this a good singleton?

2016-02-13 Thread Vladde Nordholm via Digitalmars-d-learn
Hello. I have this singleton, -- class Singleton { private this() {} static __gshared typeof(this) instance = new this; } -- and I wonder if it has any weaknesses. Or is there a better

nanosecond time

2016-02-13 Thread ishwar via Digitalmars-d-learn
I am stumped on need finding interval between two events in a program execution in nanoseconds. Any sample code will be appreciated (along with imports needed to make it work): - time in nanoseconds-now - do-some processing - time in nano-second-now Thanks

Re: nanosecond time

2016-02-13 Thread jkpl via Digitalmars-d-learn
On Saturday, 13 February 2016 at 19:24:44 UTC, ishwar wrote: I am stumped on need finding interval between two events in a program execution in nanoseconds. Any sample code will be appreciated (along with imports needed to make it work): - time in nanoseconds-now - do-some processing - time in

Re: Is this a good singleton?

2016-02-13 Thread Ali Çehreli via Digitalmars-d-learn
On 02/13/2016 10:58 AM, Vladde Nordholm wrote: Hello. I have this singleton, -- class Singleton { private this() {} static __gshared typeof(this) instance = new this; } -- and I won

Re: Is this nogc? dmd and gdc disagree

2016-02-13 Thread Kapps via Digitalmars-d-learn
On Saturday, 13 February 2016 at 00:41:35 UTC, tsbockman wrote: On Friday, 12 February 2016 at 23:46:09 UTC, Kapps wrote: You'll encounter this pretty often in Phobos I think. I really don't think @nogc is ready, and tend to avoid it in my code. Exceptions are a big reason for it, and lots of f

Re: Is this a good singleton?

2016-02-13 Thread Charles via Digitalmars-d-learn
On Saturday, 13 February 2016 at 19:32:33 UTC, Ali Çehreli wrote: David Simcha's DConf 2013 presentation has a singleton implementation at 27:55: https://www.youtube.com/watch?v=yMNMV9JlkcQ Ali Neat video! Watched the singleton section to end up watching the rest of the video. Anything ev

wrapSocket for socket_t? As wrapFile for FILE*

2016-02-13 Thread Beginner-8 via Digitalmars-d-learn
Hi! Anyone seen Socket constructor which uses already available socket of socket_t type? I am need to use already connected socket imported from C library without closing them after using.

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 February 2016 at 04:13:12 UTC, Beginner-8 wrote: Anyone seen Socket constructor which uses already available socket of socket_t type? See the list on my unofficial docs here: http://dpldocs.info/experimental-docs/std.socket.Socket.html This one does it: http://dpldocs.info/exp

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-13 Thread tcak via Digitalmars-d-learn
On Sunday, 14 February 2016 at 04:13:12 UTC, Beginner-8 wrote: Hi! Anyone seen Socket constructor which uses already available socket of socket_t type? I am need to use already connected socket imported from C library without closing them after using. One of the constructors of class Socke

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-13 Thread Beginner-8 via Digitalmars-d-learn
On Sunday, 14 February 2016 at 06:01:11 UTC, tcak wrote: Unless you explicitly call "close" method of Socket object, its descriptor will stay allocated for your process/program. Hmm, I am seen what Socket dtor contains close() too: https://github.com/D-Programming-Language/phobos/blob/master

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-13 Thread Beginner-8 via Digitalmars-d-learn
On Sunday, 14 February 2016 at 06:10:04 UTC, Beginner-8 wrote: On Sunday, 14 February 2016 at 06:01:11 UTC, tcak wrote: Unless you explicitly call "close" method of Socket object, its descriptor will stay allocated for your process/program. Hmm, I am seen what Socket dtor contains close() to

Re: Is this a good singleton?

2016-02-13 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2016-02-13 at 18:58 +, Vladde Nordholm via Digitalmars-d- learn wrote: > Hello. I have this singleton, > > -- > class Singleton > { >  private this() {} >  static __gshared typeof(this) instance = new this; > } > -

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-13 Thread Beginner-8 via Digitalmars-d-learn
(I went to make a patch to Phobos)

Re: wrapSocket for socket_t? As wrapFile for FILE*

2016-02-13 Thread Ali Çehreli via Digitalmars-d-learn
On 02/13/2016 10:38 PM, Beginner-8 wrote: On Sunday, 14 February 2016 at 06:10:04 UTC, Beginner-8 wrote: On Sunday, 14 February 2016 at 06:01:11 UTC, tcak wrote: Unless you explicitly call "close" method of Socket object, its descriptor will stay allocated for your process/program. Hmm, I am