Re: More than one invariant per struct/class

2011-08-08 Thread Pelle
On Sat, 06 Aug 2011 22:53:31 +0200, Jonathan M Davis jmdavisp...@gmx.com wrote: Feel free to create a feature request on it. It may even get the language changed. However, having more than one invariant complicates things a bit, since right now, it's easy for the runtime to just call the

Re: Multi-file byte comparison tool. What would you have done differently?

2011-08-08 Thread Pelle
On Fri, 05 Aug 2011 18:43:27 +0200, Kai Meyer k...@unixlords.com wrote: On 08/05/2011 03:02 AM, Pelle wrote: Don't declare variables until you need them, just leave bytes_read and bytes_max here. Is there a performance consideration? Or is it purely a style or D-Factor suggestion? Just

Thread Sleep

2011-08-08 Thread BizarreCake
I wonder why there isn't any sleep method in std.concurrency. I know there is one in core.thread, but I try to avoid using core modules. Maybe a sleep method is just not needed in std.concurrency? If I were to make a program that would constantly have about 60 working threads. Some kind of

Re: Thread Sleep

2011-08-08 Thread Jonathan M Davis
On Monday 08 August 2011 07:01:11 BizarreCake wrote: I wonder why there isn't any sleep method in std.concurrency. I know there is one in core.thread, but I try to avoid using core modules. Maybe a sleep method is just not needed in std.concurrency? If I were to make a program that would

Writing .di files duplicate storage

2011-08-08 Thread simendsjo
I'm writing here because I haven't been able to create a smaller example and I'm not sure what to search for in bugzilla. DMD adds a storage identifier twice when writing .di files. This is my code: /// static @property isGUIThread() { return cast(bool)IsGUIThread(false); }

Re: Writing .di files duplicate storage

2011-08-08 Thread Jonathan M Davis
On Monday 08 August 2011 09:42:15 simendsjo wrote: I'm writing here because I haven't been able to create a smaller example and I'm not sure what to search for in bugzilla. DMD adds a storage identifier twice when writing .di files. This is my code: /// static @property

Re: Writing .di files duplicate storage

2011-08-08 Thread simendsjo
On 08.08.2011 09:47, Jonathan M Davis wrote: On Monday 08 August 2011 09:42:15 simendsjo wrote: I'm writing here because I haven't been able to create a smaller example and I'm not sure what to search for in bugzilla. DMD adds a storage identifier twice when writing .di files. This is my code:

Re: Writing .di files duplicate storage

2011-08-08 Thread Brad Roberts
On Monday, August 08, 2011 12:54:00 AM, simendsjo wrote: On 08.08.2011 09:47, Jonathan M Davis wrote: http://d.puremagic.com/issues/show_bug.cgi?id=6360 Thanks. The annoying thing is that I have to manually modify the import library :| Could spend the time fixing dmd instead of working

Re: Writing .di files duplicate storage

2011-08-08 Thread simendsjo
On 08.08.2011 09:57, Brad Roberts wrote: On Monday, August 08, 2011 12:54:00 AM, simendsjo wrote: On 08.08.2011 09:47, Jonathan M Davis wrote: http://d.puremagic.com/issues/show_bug.cgi?id=6360 Thanks. The annoying thing is that I have to manually modify the import library :| Could spend

Re: More than one invariant per struct/class

2011-08-08 Thread simendsjo
On 06.08.2011 22:53, Jonathan M Davis wrote: On Saturday 06 August 2011 22:40:15 simendsjo wrote: On 04.08.2011 11:32, simendsjo wrote: I would like to use a template mixin to add some fields to a struct, but I'd also like the template to add additional invariant checks without having to

Re: Writing .di files duplicate storage

2011-08-08 Thread simendsjo
On 08.08.2011 10:01, simendsjo wrote: On 08.08.2011 09:47, Jonathan M Davis wrote: On Monday 08 August 2011 09:42:15 simendsjo wrote: I'm writing here because I haven't been able to create a smaller example and I'm not sure what to search for in bugzilla. DMD adds a storage identifier twice

formattedWrite

2011-08-08 Thread simendsjo
I cannot find any string format() method in phobos. Having to do: auto a = appender!string(); formattedWrite(a, , ...); a.data seems unnecessary in many cases.

Re: formattedWrite

2011-08-08 Thread Vladimir Panteleev
On Mon, 08 Aug 2011 14:37:26 +0300, simendsjo simend...@gmail.com wrote: I cannot find any string format() method in phobos. What's wrong with format() from std.string? -- Best regards, Vladimirmailto:vladi...@thecybershadow.net

Re: formattedWrite

2011-08-08 Thread simendsjo
On 08.08.2011 13:37, Vladimir Panteleev wrote: On Mon, 08 Aug 2011 14:37:26 +0300, simendsjo simend...@gmail.com wrote: I cannot find any string format() method in phobos. What's wrong with format() from std.string? Thanks, that was the function I was looking for. I just expected it to

Re: formattedWrite

2011-08-08 Thread simendsjo
On 08.08.2011 13:41, simendsjo wrote: On 08.08.2011 13:37, Vladimir Panteleev wrote: On Mon, 08 Aug 2011 14:37:26 +0300, simendsjo simend...@gmail.com wrote: I cannot find any string format() method in phobos. What's wrong with format() from std.string? Thanks, that was the function I

Unittesting libraries

2011-08-08 Thread simendsjo
Is it possible to run unittests in libraries? The following doesn't work: l.d === module l; import std.stdio; int f() { return 1; } // just to make sure it's actually compiled in unittest { writeln(Unittest from lib); assert(false); } t.d === import l; import std.stdio; void main() {

Re: formattedWrite

2011-08-08 Thread simendsjo
On 08.08.2011 14:07, simendsjo wrote: On 08.08.2011 13:41, simendsjo wrote: On 08.08.2011 13:37, Vladimir Panteleev wrote: On Mon, 08 Aug 2011 14:37:26 +0300, simendsjo simend...@gmail.com wrote: I cannot find any string format() method in phobos. What's wrong with format() from

Re: Writing .di files duplicate storage

2011-08-08 Thread Steven Schveighoffer
On Mon, 08 Aug 2011 04:01:17 -0400, simendsjo simend...@gmail.com wrote: On 08.08.2011 09:47, Jonathan M Davis wrote: On Monday 08 August 2011 09:42:15 simendsjo wrote: I'm writing here because I haven't been able to create a smaller example and I'm not sure what to search for in bugzilla.

DDoc adds filename as given on dmd command line in comment

2011-08-08 Thread simendsjo
I use absolute paths in a build script, and Ddoc uses the full path in a comment in the generated files. This makes version control very difficult as all developers has to use the same location (and possibly operating system). Is there a way to avoid this without changing by build script?

Re: Writing .di files duplicate storage

2011-08-08 Thread simendsjo
On 08.08.2011 15:33, Steven Schveighoffer wrote: On Mon, 08 Aug 2011 04:01:17 -0400, simendsjo simend...@gmail.com wrote: On 08.08.2011 09:47, Jonathan M Davis wrote: On Monday 08 August 2011 09:42:15 simendsjo wrote: I'm writing here because I haven't been able to create a smaller example

Re: Writing .di files duplicate storage

2011-08-08 Thread bearophile
simendsjo: Is this by design, or just an implementation oddity? Or a design oddity? Bye, bearophile

IDispatch/activex objects in 2011

2011-08-08 Thread Jason King
I need to interface with an application that has an IDispatch (activex/ole/automation) interface. I can find some threads from 2006 about how painful that was. I'm suspecting that in the intervening 5 years progress has been made, but I'm having trouble finding it. The manual says D

Re: IDispatch/activex objects in 2011

2011-08-08 Thread simendsjo
On 08.08.2011 15:46, Jason King wrote: I need to interface with an application that has an IDispatch (activex/ole/automation) interface. I can find some threads from 2006 about how painful that was. I'm suspecting that in the intervening 5 years progress has been made, but I'm having trouble

Re: Multi-file byte comparison tool. What would you have done differently?

2011-08-08 Thread Kai Meyer
On 08/08/2011 12:33 AM, Pelle wrote: On Fri, 05 Aug 2011 18:43:27 +0200, Kai Meyer k...@unixlords.com wrote: On 08/05/2011 03:02 AM, Pelle wrote: Don't declare variables until you need them, just leave bytes_read and bytes_max here. Is there a performance consideration? Or is it purely a

We have slices, do we have Strides?

2011-08-08 Thread Kai Meyer
I have a problem I'd really like to use Strides for to simplify my code. Currently, I do this: foreach(n; 0..chunks) comp_arr[n] = values[(n * step_size) + n] if(!all_same(comp_arr, comp_arr[0])) It would eliminate an entire 2 lines of code for each time I want

Re: We have slices, do we have Strides?

2011-08-08 Thread Jonathan M Davis
I have a problem I'd really like to use Strides for to simplify my code. Currently, I do this: foreach(n; 0..chunks) comp_arr[n] = values[(n * step_size) + n] if(!all_same(comp_arr, comp_arr[0])) It would eliminate an entire 2 lines of code for each time I want strides, to be able to do

Re: Foreach over tuple of arrays?

2011-08-08 Thread Philippe Sigaud
Hi Sean, This doesn't work when passing a delegate as func, however. Is there a way to circumvent this? I tried this with a delegate and a function template, it seems to work: import std.typecons; void bar(T)(ref T elem) { elem = elem+1; } void main() { auto data = tuple([0,1,2,3],

Tuple [] operator

2011-08-08 Thread Christian Manning
Hi, I'm receiving this error with dmd 2.054: tmp.d(7): Error: no [] operator overload for type Tuple!(int,short) for the following test case import std.typecons; void main() { auto x = 1; Tuple!(int,short) a; a[0] = 1; a[x] = 2; } If I use a value instead of a variable ie. a[1] = 2; it compiles

Re: Foreach over tuple of arrays?

2011-08-08 Thread Philippe Sigaud
Hmm, I just saw your question on SO. Is that nearer to what you ask? It uses a anonymous template function: import std.typecons; void act(alias fun, T...)(ref Tuple!T data) { foreach(index, range; data.expand) foreach(ref element; range) fun(element); } void main() {

Re: Tuple [] operator

2011-08-08 Thread Philippe Sigaud
Hi Chris, import std.typecons; void main() { auto x = 1; Tuple!(int,short) a; a[0] = 1; a[x] = 2; } If I use a value instead of a variable ie. a[1] = 2; it compiles fine. The index need to be a compile-time constant, you cannot index a tuple with a runtime value. Try using enum x = 1;

Re: Modify thread-local storage from parent thread

2011-08-08 Thread Steven Schveighoffer
On Mon, 08 Aug 2011 14:17:28 -0400, Kai Meyer k...@unixlords.com wrote: I am playing with threading, and I am doing something like this: file.rawRead(bytes); auto tmpTask = task!do_something(bytes.idup); task_pool.put(tmpTask); Is there a way to avoid the idup (or can

Re: Tuple [] operator

2011-08-08 Thread Dmitry Olshansky
On 08.08.2011 23:27, Christian Manning wrote: Hi, I'm receiving this error with dmd 2.054: tmp.d(7): Error: no [] operator overload for type Tuple!(int,short) for the following test case import std.typecons; void main() { auto x = 1; Tuple!(int,short) a; a[0] = 1; a[x] = 2; } If I use a value

Re: Tuple [] operator

2011-08-08 Thread Christian Manning
Philippe Sigaud wrote: Hi Chris, import std.typecons; void main() { auto x = 1; Tuple!(int,short) a; a[0] = 1; a[x] = 2; } If I use a value instead of a variable ie. a[1] = 2; it compiles fine. The index need to be a compile-time constant, you cannot index a tuple with a runtime

Re: Tuple [] operator

2011-08-08 Thread Steven Schveighoffer
On Mon, 08 Aug 2011 15:47:36 -0400, Christian Manning cmanning...@gmail.com wrote: Philippe Sigaud wrote: Hi Chris, import std.typecons; void main() { auto x = 1; Tuple!(int,short) a; a[0] = 1; a[x] = 2; } If I use a value instead of a variable ie. a[1] = 2; it compiles fine. The index

Re: Tuple [] operator

2011-08-08 Thread Ali Çehreli
On Mon, 08 Aug 2011 15:55:38 -0400, Steven Schveighoffer wrote: On Mon, 08 Aug 2011 15:47:36 -0400, Christian Manning cmanning...@gmail.com wrote: [...] auto x = 1; Tuple!(int, short) a; a[0] = 1; switch(x) { case 0: a[0] = 2; break; case 1: a[1] = 2; Those

Re: Tuple [] operator

2011-08-08 Thread Ali Çehreli
On Mon, 08 Aug 2011 20:32:03 +, Ali Çehreli wrote: the point is, the compiler has no idea what the lvalue expression's type should be when you do: a[x] = 1; is it short or int? so the compiler must *know* what type x is at compile time in order for this to be valid. I think

Re: Tuple [] operator

2011-08-08 Thread Philippe Sigaud
On Mon, Aug 8, 2011 at 21:55, Steven Schveighoffer schvei...@yahoo.com wrote: You still can do it, but you have to do it by still using compile-time constants as indexes: auto x = 1; Tuple!(int, short) a; a[0] = 1; switch(x) { case 0:   a[0] = 2;   break; case 1:   a[1] = 2;  

Re: Tuple [] operator

2011-08-08 Thread Christian Manning
Philippe Sigaud wrote: On Mon, Aug 8, 2011 at 21:55, Steven Schveighoffer schvei...@yahoo.com wrote: You still can do it, but you have to do it by still using compile-time constants as indexes: auto x = 1; Tuple!(int, short) a; a[0] = 1; switch(x) { case 0: a[0] = 2; break; case

Re: We have slices, do we have Strides?

2011-08-08 Thread Kai Meyer
On 08/08/2011 12:55 PM, Jonathan M Davis wrote: I have a problem I'd really like to use Strides for to simplify my code. Currently, I do this: foreach(n; 0..chunks) comp_arr[n] = values[(n * step_size) + n] if(!all_same(comp_arr, comp_arr[0])) It would eliminate an entire 2 lines of code for

Re: We have slices, do we have Strides?

2011-08-08 Thread Jonathan M Davis
On 08/08/2011 12:55 PM, Jonathan M Davis wrote: I have a problem I'd really like to use Strides for to simplify my code. Currently, I do this: foreach(n; 0..chunks) comp_arr[n] = values[(n * step_size) + n] if(!all_same(comp_arr, comp_arr[0])) It would eliminate an entire 2 lines

Re: We have slices, do we have Strides?

2011-08-08 Thread Steven Schveighoffer
On Mon, 08 Aug 2011 18:33:55 -0400, Kai Meyer k...@unixlords.com wrote: On 08/08/2011 12:55 PM, Jonathan M Davis wrote: I have a problem I'd really like to use Strides for to simplify my code. Currently, I do this: foreach(n; 0..chunks) comp_arr[n] = values[(n * step_size) + n]

Permission denied under Ubuntu.

2011-08-08 Thread Charles McAnany
Hi, all. I installed dmd_2.054-0_amd64.deb on Ubuntu 11.04, and the compiler seems to work fine, but I can't execute its output. Here's what I'm doing: (ls to show directory contents) $ dmd testFile.d $ ./testFile bash: ./testFile: Permission denied testFile.d is the Hello world program

Re: We have slices, do we have Strides?

2011-08-08 Thread Jonathan M Davis
On Mon, 08 Aug 2011 18:33:55 -0400, Kai Meyer k...@unixlords.com wrote: On 08/08/2011 12:55 PM, Jonathan M Davis wrote: I have a problem I'd really like to use Strides for to simplify my code. Currently, I do this: foreach(n; 0..chunks) comp_arr[n] = values[(n * step_size) + n]

Re: Tuple [] operator

2011-08-08 Thread Andrej Mitrovic
On 8/8/11, Steven Schveighoffer schvei...@yahoo.com wrote: I like this idea. I think it belongs in phobos somewhere, if not already. -Steve Allow me to +1 on that, I've had a need for this (but now I can't remember why, hah!).

Tuple vs struct performance?

2011-08-08 Thread bearophile
Do you know the cause of the large (something like 3 times, latest dmd, -O -release -inline) difference in performance in this program from using a tuple or a struct with the same fields (the two alternative lines near the top)? http://codepad.org/dLLdgrq8 I have tried in various ways to

Re: Permission denied under Ubuntu.

2011-08-08 Thread Andrew Wiley
On Mon, Aug 8, 2011 at 4:30 PM, Charles McAnany mcana...@rose-hulman.eduwrote: Hi, all. I installed dmd_2.054-0_amd64.deb on Ubuntu 11.04, and the compiler seems to work fine, but I can't execute its output. Here's what I'm doing: (ls to show directory contents) $ dmd testFile.d $

Re: Tuple [] operator

2011-08-08 Thread Philippe Sigaud
Sorry, wasn't me... Oops, sorry. I like this idea.  I think it belongs in phobos somewhere, if not already. I remember getting the idea in one of the articles written to win an iPad2 a few months ago. Philippe

Subclass template arguments from a non-templated interface

2011-08-08 Thread Callum Anderson
I have the following (sort of) situation: interface Handle { } class A(T...) : Handle { T[0] m_one; T[1] m_two; etc.. T[0] getOne() { return m_one; } } class B { Handle[] m_array; } The reason I want to inherit A from Handle is so I don't have to keep using the