Re: On Concurrency

2014-04-20 Thread via Digitalmars-d-learn
On Friday, 18 April 2014 at 17:20:06 UTC, Nordlöw wrote: Could someone please give some references to thorough explainings on these latest concurrency mechanisms Coroutines is nothing more than explicit stack switching. Goroutines/fiber etc are abstractions that may be implemented using corou

Re: async socket programming in D?

2014-04-20 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-04-21 00:32, Etienne Cimon wrote: On 2014-04-20 18:44, Bauss wrote: I know the socket has the nonblocking settings, but how would I actually go around using it in D? Is there a specific procedure for it to work correctly etc. I've taken a look at splat.d but it seems to be very outdate

Re: async socket programming in D?

2014-04-20 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-04-20 18:44, Bauss wrote: I know the socket has the nonblocking settings, but how would I actually go around using it in D? Is there a specific procedure for it to work correctly etc. I've taken a look at splat.d but it seems to be very outdated, so that's why I went ahead and asked her

Re: On Concurrency

2014-04-20 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-04-18 13:20, "Nordlöw" wrote: Could someone please give some references to thorough explainings on these latest concurrency mechanisms - Go: Goroutines - Coroutines (Boost): - https://en.wikipedia.org/wiki/Coroutine - http://www.boost.org/doc/libs/1_55_0/libs/coroutine/doc/html/cor

Re: async socket programming in D?

2014-04-20 Thread Tolga Cakiroglu via Digitalmars-d-learn
On Sunday, 20 April 2014 at 22:44:28 UTC, Bauss wrote: I know the socket has the nonblocking settings, but how would I actually go around using it in D? Is there a specific procedure for it to work correctly etc. I've taken a look at splat.d but it seems to be very outdated, so that's why I

Re: Function to print a diamond shape

2014-04-20 Thread Jay Norwood via Digitalmars-d-learn
On Tuesday, 25 March 2014 at 08:42:30 UTC, monarch_dodra wrote: Interesting. I'd have thought the "extra copy" would be an overall slowdown, but I guess that's not the case. I installed ubuntu 14.04 64 bit, and measured some of these examples using gdc, ldc and dmd on a corei3 box. The ex

async socket programming in D?

2014-04-20 Thread Bauss via Digitalmars-d-learn
I know the socket has the nonblocking settings, but how would I actually go around using it in D? Is there a specific procedure for it to work correctly etc. I've taken a look at splat.d but it seems to be very outdated, so that's why I went ahead and asked here as I'd probably have to end u

Re: Structs insted of classes for Performance

2014-04-20 Thread anonymous via Digitalmars-d-learn
On Sunday, 20 April 2014 at 18:08:19 UTC, Frustrated wrote: In D though, I guess because of the GC(but which is why I am asking because I don't know specifically), classes could be much slower due to all the references causing the GC to take longer scan the heap and all that. If allocate or fre

Re: string -> string literal

2014-04-20 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 20 April 2014 at 17:55:25 UTC, Ellery Newcomer wrote: is there a function in phobos anywhere that takes a string and escapes it into a string literal suitable for string mixins? something like assert (f("abc\ndef") == "\"abc\\ndef\""); It's a bit hackish, but it avoids deploying c

Re: Structs insted of classes for Performance

2014-04-20 Thread Frustrated via Digitalmars-d-learn
On Sunday, 20 April 2014 at 16:56:59 UTC, Ali Çehreli wrote: My understanding is not perfect. There may be compiler and CPU optimizations that I am not aware of. On 04/20/2014 08:03 AM, Frustrated wrote: > is the only argument really about performance when creating > structs vs creating classe

string -> string literal

2014-04-20 Thread Ellery Newcomer via Digitalmars-d-learn
is there a function in phobos anywhere that takes a string and escapes it into a string literal suitable for string mixins? something like assert (f("abc\ndef") == "\"abc\\ndef\"");

Re: Structs insted of classes for Performance

2014-04-20 Thread Ali Çehreli via Digitalmars-d-learn
My understanding is not perfect. There may be compiler and CPU optimizations that I am not aware of. On 04/20/2014 08:03 AM, Frustrated wrote: > is the only argument really about performance when creating > structs vs creating classes Not only creating but also when using. A class variable is

Re: Get and set terminal size

2014-04-20 Thread Denis Mezhov via Digitalmars-d-learn
On Saturday, 19 April 2014 at 12:06:58 UTC, FreeSlave wrote: I use ldc2 main.d -L-lcurses or dmd main.d -L-lcurses and following source code: import std.stdio; extern(C) int tgetnum(const(char) *id); int main() { writeln(tgetnum("li")); return 0; } Note that you don't need to apply t

Re: number formatting

2014-04-20 Thread JR via Digitalmars-d-learn
On Sunday, 20 April 2014 at 12:53:11 UTC, steven kladitis wrote: Note sure if you can edit messages once sent. $13,456.67 245,678,541 On Sunday, 20 April 2014 at 12:50:52 UTC, steven kladitis wrote: How do you format numbers to have things like. Leading $ or , or with or without leading ze

Structs insted of classes for Performance

2014-04-20 Thread Frustrated via Digitalmars-d-learn
I know the difference between a struct and a class but I remember seeing somewhere that structs are much faster than classes in D for some strange reason. I'm not worried too much about class allocation performance because I will try and use classes when they will not be created frequently an

Re: number formatting

2014-04-20 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 20 April 2014 at 12:53:11 UTC, steven kladitis wrote: Note sure if you can edit messages once sent. $13,456.67 245,678,541 On Sunday, 20 April 2014 at 12:50:52 UTC, steven kladitis wrote: How do you format numbers to have things like. Leading $ or , or with or without leading ze

number formatting

2014-04-20 Thread steven kladitis via Digitalmars-d-learn
How do you format numbers to have things like. Leading $ or , or with or without leading zeros. for example $56.00 $056.00 $1,3456.67 <345.89>CR

Re: number formatting

2014-04-20 Thread steven kladitis via Digitalmars-d-learn
Note sure if you can edit messages once sent. $13,456.67 245,678,541 On Sunday, 20 April 2014 at 12:50:52 UTC, steven kladitis wrote: How do you format numbers to have things like. Leading $ or , or with or without leading zeros. for example $56.00 $056.00 $1,

Re: std.file.read returns void[] why?

2014-04-20 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/18/14, monarch_dodra via Digitalmars-d-learn wrote: > Yeah... "static assert(void.sizeof == 1);" passes :/ Note that you can even have static void arrays. E.g.: https://issues.dlang.org/show_bug.cgi?id=9691 I'm not sure whether this is an oversight (accepts-invalid) or something else. But

Re: Template method and type resolution of return type

2014-04-20 Thread matovitch via Digitalmars-d-learn
On Sunday, 20 April 2014 at 08:28:07 UTC, monarch_dodra wrote: On Sunday, 20 April 2014 at 07:52:08 UTC, matovitch wrote: struct S { ubyte get() { return 0 ; } float get() { return 0.; } } void main() { S s; float x = s.get(); // does'nt know which overload, does'nt compile. } W

Re: Template method and type resolution of return type

2014-04-20 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 20 April 2014 at 07:52:08 UTC, matovitch wrote: struct S { ubyte get() { return 0 ; } float get() { return 0.; } } void main() { S s; float x = s.get(); // does'nt know which overload, does'nt compile. } What I do find interesting though, is that you are allowed to

Re: Template method and type resolution of return type

2014-04-20 Thread matovitch via Digitalmars-d-learn
On Sunday, 20 April 2014 at 00:55:31 UTC, David Held wrote: On 4/19/2014 3:31 PM, Andrej Mitrovic via Digitalmars-d-learn wrote: [...] struct S { int get() { return 0; } T get(T)() { return T.init; } } void main() { S s; float x = s.get(); // which overload? (currently int ge