Re: is there a cleaner way to new a static sized array?

2010-02-24 Thread daoryn
BCS Wrote: > I need a function that works like the following: > > > T* New(T)() { return new T; } > > But that also works with static arrays: > > > auto i = New!(int)(); > > auto a = New!(int[27])(); > > The cleanest solution I can think of is: > > > T* New(T)() { return (new T[1]).ptr; } >

Re: Simple Socket Server Code

2010-02-24 Thread daoryn
sybrandy Wrote: > All, > > Does anyone know where I can get a simple example of writing a server in > D? Just a stupid little echo server would be fine. I'm trying to write > one myself, but for some reason it doesn't seem to be accepting any > connections. I figure it's something stupidly

Re: running an external .exe

2010-02-17 Thread daoryn
Funog Wrote: > Is it possible to run an external .exe and have access to its standard > input/output? Apparently std.process does not allow this. > You can try loading the .exe into memory as a library (dll) and passing the .exe's entry point (main) to a thread (core.thread.Thread). Just a ran

Re: How DMD's -w *Prevents* Me From Seeing My Warnings

2010-02-13 Thread daoryn
strtr Wrote: > or: Why does dmd keep on crashing on my code :) > (I blame it on the average D programming; they don't write enough crappy code > ) > > After reading the -w post I tried using the -w switch again and it also > prevents me from seeing all my warning, but for a different reason :

Re: Unexpected behaviour on socket

2010-02-10 Thread daoryn
> > The buffer you are passing to receive is 0 bytes long. The > std.socket.Socket.receive function is a wrapper over the normal socket > function, and includes a test for an empty buffer. > > Daniel Ohh, I see. Thank you! I thought that the function would resize the buffer accordingly. Than

Re: template specialization question

2010-02-01 Thread daoryn
Tomek Sowiński Wrote: > Dnia 31-01-2010 o 21:39:21 Ali Çehreli napisał(a): > > > � wrote: > >> Dnia 31-01-2010 o 20:59:47 Tomek Sowi�ski napisa�(a): > >> > >>> // specialization needed to limit matching types > >>> void print(T:int)(T thing) > >> To be clear -- I did this to silence t

Re: template specialization question

2010-02-01 Thread daoryn
> It works with dmd 2.040 without the :int specialization. No it doesnt. Did you use specific compiler flags? Also check that you are using the source I posted and not the modified versions presented which served only to circumvent compiler warnings and not answer the original question: is it a

Re: template specialization question

2010-02-01 Thread daoryn
y whether this belongs in bugzilla or not. It might. > > On 01/31/2010 12:49 PM, daoryn wrote: > > > > > I expected it to output "calling print(T[])" on the second "print". Would > > this be a bug or did I misunderstand the template specialization?

Re: template specialization question

2010-02-01 Thread daoryn
Daniel Murphy Wrote: > daoryn Wrote: > > > According to http://digitalmars.com/d/2.0/template.html it is possible to > > specify template specialization so that DMD prefers them when instanciating > > templates, ho

template specialization question

2010-01-31 Thread daoryn
According to http://digitalmars.com/d/2.0/template.html it is possible to specify template specialization so that DMD prefers them when instanciating templates, however the following code: - import std.stdio; void print(T)(T thing) { writeln("Calling pri

Thread control in D2

2010-01-02 Thread Daoryn
In Phobos D1 the functions we have the functions "suspend" and "resume", however, these functions seem to be gone on Phobos D2. Is there any particular reason why this functionality has been removed? What other ways do I have to pause/resume a specific thread?