Re: Circular Buffer

2013-12-21 Thread ponce
On Friday, 20 December 2013 at 15:45:04 UTC, Frustrated wrote: I'm in need of a circular buffer/array. I am using std.container.array to avoid the GC. I suppose I could copy and modify the code but is there any easier way? It looks like it is defined as templates so could I somehow hijack the

Compiling D inside of a D program

2013-12-21 Thread Mineko
This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler, whichever that might be from inside of a D program, so I can say, compile a D script on-the-fly in some game, it's just an idea though. To be even more to

Re: Compiling D inside of a D program

2013-12-21 Thread thedeemon
On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote: To be even more to the point, how can I invoke the D compiler inside of a D program, also, do I need to bundle said D compiler with my program or does D have some compilation feature inside of an already compiled program (Which I

Re: Compiling D inside of a D program

2013-12-21 Thread Andrea Fontana
I still hope they make DMD available as shared/static library just like tinyc compiler! On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote: This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler,

Re: Compiling D inside of a D program

2013-12-21 Thread Kelet
On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote: This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler, whichever that might be from inside of a D program, so I can say, compile a D script on-the-fly

Re: Circular Buffer

2013-12-21 Thread simendsjo
On Friday, 20 December 2013 at 15:45:04 UTC, Frustrated wrote: I'm in need of a circular buffer/array. I am using std.container.array to avoid the GC. I suppose I could copy and modify the code but is there any easier way? It looks like it is defined as templates so could I somehow hijack the

Re: a[++i] = i vs a[i] = ++i

2013-12-21 Thread aldanor
On Saturday, 21 December 2013 at 02:56:57 UTC, Dicebot wrote: No. There is no such thing as suitable compiler warning. So should this considered a bug then and be filed? (if that will do any good, lol)

Re: Removing multiple elements from array

2013-12-21 Thread aldanor
On Saturday, 21 December 2013 at 03:22:22 UTC, H. S. Teoh wrote: Unfortunately, while std.algorithm.remove does provide a way to do this if the number of indices to remove are known beforehand, it doesn't seem to be able to remove a dynamic list of indices. Probably an enhancement request

Re: Removing multiple elements from array

2013-12-21 Thread aldanor
On Saturday, 21 December 2013 at 02:52:00 UTC, bearophile wrote: Do not forget to add the () after the sort, otherwise you call the deprecated, buggy and slow built-in sort. reverse is another deprecated built-in, so use retro. The first if is not much useful, trying to sort an empty array

Re: a[++i] = i vs a[i] = ++i

2013-12-21 Thread bearophile
aldanor: So should this considered a bug then and be filed? I think so. I have a related EnhancementRequest open, but I have to close it down or modify it... Bye, bearophile

Dub and GtkD

2013-12-21 Thread Russel Winder
I just created a new vibe.d project using dub, all fine. Well once I had solved the libevent problem. Then, as the project is to be a GUI client, I added a gtk-d dependency. I tried building the empty project and the binary comes out at 42MB. Not only that there are two copies of it one in . and

Vibe.d and testing

2013-12-21 Thread Russel Winder
Is there a way of mocking the TCPConnect call so as to create a connection to a mock instead of the real device so as to be able to integration test and system test a vibe.d-based client? -- Russel. = Dr Russel Winder

Re: Thrift maintained..?

2013-12-21 Thread David Eagen
On Friday, 15 November 2013 at 21:11:36 UTC, simendsjo wrote: I thrid compiling thrift 0.9.1 from github with d support, but there's a bug in the makefile it seems. $(addprefix.log: $(addprefix @p='$(addprefix'; \ b='$(addprefix'; \ $(am__check_pre) $(LOG_DRIVER)

Re: Thrift maintained..?

2013-12-21 Thread Ali Çehreli
On 11/15/2013 01:11 PM, simendsjo wrote: I thrid compiling thrift 0.9.1 from github with d support, but there's a bug in the makefile it seems. $(addprefix.log: $(addprefix @p='$(addprefix'; \ b='$(addprefix'; \ $(am__check_pre) $(LOG_DRIVER) --test-name $$f \

Re: Thrift maintained..?

2013-12-21 Thread Martin Nowak
On Friday, 15 November 2013 at 21:11:36 UTC, simendsjo wrote: I thrid compiling thrift 0.9.1 from github with d support, but there's a bug in the makefile it seems. $(addprefix.log: $(addprefix @p='$(addprefix'; \ b='$(addprefix'; \ $(am__check_pre) $(LOG_DRIVER)

Why is compilation failing with this selective import?

2013-12-21 Thread Nick Hamann
I'm not sure if this is a bug or if I'm doing something wrong. Compilation succeeds and the program runs successfully with this code: import std.stdio; import std.conv : to; void main() { auto x = std.conv.to!double(7.3); writeln(x - 2.2); } However, when I change the first line to

Re: Why is compilation failing with this selective import?

2013-12-21 Thread Timon Gehr
On 12/21/2013 09:56 PM, Nick Hamann wrote: I'm not sure if this is a bug or if I'm doing something wrong. Compilation succeeds and the program runs successfully with this code: import std.stdio; import std.conv : to; void main() { auto x = std.conv.to!double(7.3); writeln(x - 2.2); }

Re: Removing multiple elements from array

2013-12-21 Thread MrSmith
On Saturday, 21 December 2013 at 00:47:04 UTC, aldanor wrote: Is there an efficient method to remove elements with multiple (compile-time-unknown) indices from an array? I currently do something like if (!index.empty) foreach (i; index.sort.reverse)

Re: Compiling D inside of a D program

2013-12-21 Thread Mineko
On Saturday, 21 December 2013 at 10:00:10 UTC, Kelet wrote: On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote: This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able to invoke the D compiler, whichever that might be from inside

Re: Compiling D inside of a D program

2013-12-21 Thread John Colvin
On Saturday, 21 December 2013 at 21:58:16 UTC, Mineko wrote: On Saturday, 21 December 2013 at 10:00:10 UTC, Kelet wrote: On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote: This is a fairly basic question but I can't find any good answers, so I'm asking.. Anyways, I want to be able

Re: Dub and GtkD

2013-12-21 Thread Jacob Carlborg
On 2013-12-21 15:51, Russel Winder wrote: I just created a new vibe.d project using dub, all fine. Well once I had solved the libevent problem. Then, as the project is to be a GUI client, I added a gtk-d dependency. I tried building the empty project and the binary comes out at 42MB. Not only

Re: Compiling D inside of a D program

2013-12-21 Thread Mineko
On Saturday, 21 December 2013 at 22:07:42 UTC, John Colvin wrote: To the best of my knowledge it's totally ok to have your program download the latest zip from dlang.org on the client machine and use that. Sounds good to me, I more or less know what to do now, I'll be using DMD because of

Re: Dub and GtkD

2013-12-21 Thread qznc
On Saturday, 21 December 2013 at 14:52:08 UTC, Russel Winder wrote: I just created a new vibe.d project using dub, all fine. Well once I had solved the libevent problem. Then, as the project is to be a GUI client, I added a gtk-d dependency. I tried building the empty project and the binary

ubytes to ulong problem

2013-12-21 Thread Charles Hixson
I was planning to ask if there were a better way to do this, but instead I need to ask what's my mistake? For some reason, if called with an uninitialized ubyte array, and an index of 0, it returns a value of 8, even though all the values in the array are 0. The error has to be somewhere in the

Re: ubytes to ulong problem

2013-12-21 Thread ponce
On Saturday, 21 December 2013 at 22:29:59 UTC, ponce wrote: On Saturday, 21 December 2013 at 22:22:09 UTC, Charles Hixson wrote: I was planning to ask if there were a better way to do this, but instead I need to ask what's my mistake? For some reason, if called with an uninitialized ubyte

Re: Compiling D inside of a D program

2013-12-21 Thread John Colvin
On Saturday, 21 December 2013 at 22:18:58 UTC, Mineko wrote: On Saturday, 21 December 2013 at 22:07:42 UTC, John Colvin wrote: To the best of my knowledge it's totally ok to have your program download the latest zip from dlang.org on the client machine and use that. Sounds good to me, I

Re: Compiling D inside of a D program

2013-12-21 Thread Mineko
On Saturday, 21 December 2013 at 22:51:53 UTC, John Colvin wrote: On Saturday, 21 December 2013 at 22:18:58 UTC, Mineko wrote: On Saturday, 21 December 2013 at 22:07:42 UTC, John Colvin wrote: To the best of my knowledge it's totally ok to have your program download the latest zip from

Re: ubytes to ulong problem

2013-12-21 Thread John Colvin
On Saturday, 21 December 2013 at 22:22:09 UTC, Charles Hixson wrote: I was planning to ask if there were a better way to do this, but instead I need to ask what's my mistake? For some reason, if called with an uninitialized ubyte array, and an index of 0, it returns a value of 8, even though

Re: Compiling D inside of a D program

2013-12-21 Thread John Colvin
On Saturday, 21 December 2013 at 23:00:20 UTC, Mineko wrote: On Saturday, 21 December 2013 at 22:51:53 UTC, John Colvin wrote: On Saturday, 21 December 2013 at 22:18:58 UTC, Mineko wrote: On Saturday, 21 December 2013 at 22:07:42 UTC, John Colvin wrote: To the best of my knowledge it's

sending an Exception and print it

2013-12-21 Thread Dan Killebrew
I'm sending an exception from a worker thread to the owner thread to be logged/printed. Using DMD64 D Compiler v2.064 http://dpaste.dzfl.pl/7c8b68bd Using std.concurrency prevents me from passing a naked Exception. So the owner receives either a shared or immutable Exception. I can't format a

Re: sending an Exception and print it

2013-12-21 Thread Dan Killebrew
I just wanted to add that the can't format immutable Exception also prevents me from doing this: auto exception = receiveOnly!(immutable Exception)(); because receiveOnly creates a tuple which implements a toString that uses indirectly uses formatObject. So I'm forced to use the slightly

Re: ubytes to ulong problem

2013-12-21 Thread Charles Hixson
On 12/21/2013 02:31 PM, ponce wrote: On Saturday, 21 December 2013 at 22:29:59 UTC, ponce wrote: On Saturday, 21 December 2013 at 22:22:09 UTC, Charles Hixson wrote: I was planning to ask if there were a better way to do this, but instead I need to ask what's my mistake? For some reason, if

Re: ubytes to ulong problem

2013-12-21 Thread Ali Çehreli
On 12/21/2013 03:13 PM, John Colvin wrote: Ideally the compiler will optimise your version to be fast, but you may find you get better performance by doing the bit manipulations eplicitly: Assuming that the program needs to support only big endian and little endian systems (i.e. excluding

Re: ubytes to ulong problem

2013-12-21 Thread John Colvin
On Saturday, 21 December 2013 at 23:52:05 UTC, Ali Çehreli wrote: On 12/21/2013 03:13 PM, John Colvin wrote: Ideally the compiler will optimise your version to be fast, but you may find you get better performance by doing the bit manipulations eplicitly: Assuming that the program needs to

const char* or const(char)* when porting C headers?

2013-12-21 Thread Gary Willoughby
When porting C headers which include function declarations with using char* types. Is it best to use const char* or const(char)* as the type in the D declaration?

Re: const char* or const(char)* when porting C headers?

2013-12-21 Thread Adam D. Ruppe
On Sun, Dec 22, 2013 at 12:47:45AM +, Gary Willoughby wrote: When porting C headers which include function declarations with using char* types. Is it best to use const char* or const(char)* as the type in the D declaration? Doesn't really matter: both work exactly the same way. I kinda

Re: Removing multiple elements from array

2013-12-21 Thread aldanor
On Saturday, 21 December 2013 at 21:49:01 UTC, MrSmith wrote: On Saturday, 21 December 2013 at 00:47:04 UTC, aldanor wrote: Is there an efficient method to remove elements with multiple (compile-time-unknown) indices from an array? I currently do something like if

Re: ubytes to ulong problem

2013-12-21 Thread Charles Hixson
On 12/21/2013 03:52 PM, Ali Çehreli wrote: On 12/21/2013 03:13 PM, John Colvin wrote: Ideally the compiler will optimise your version to be fast, but you may find you get better performance by doing the bit manipulations eplicitly: Assuming that the program needs to support only big endian

Re: ubytes to ulong problem

2013-12-21 Thread Ali Çehreli
On 12/21/2013 05:44 PM, Charles Hixson wrote: On 12/21/2013 03:52 PM, Ali Çehreli wrote: On 12/21/2013 03:13 PM, John Colvin wrote: Ideally the compiler will optimise your version to be fast, but you may find you get better performance by doing the bit manipulations eplicitly: Assuming that

Re: const char* or const(char)* when porting C headers?

2013-12-21 Thread Alexandr Druzhinin
22.12.2013 07:47, Gary Willoughby пишет: When porting C headers which include function declarations with using char* types. Is it best to use const char* or const(char)* as the type in the D declaration? C vs D const char* == const(char)* const char const* == const char*