Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread Jacob Carlborg
On 2014-01-16 21:26, Gary Willoughby wrote: What i would like to achieve is to dynamically assign and retrieve properties without declaring them first. For example: class T { public this() { this.foo = bar; } } Ordinarily the above won't compile because 'foo' hasn't

thisExePath and rdmd

2014-01-17 Thread Andrea Fontana
thisExePath returns the full path of the current executable. If I run something like ./mysource.d (using rdmd shebang) it returns the full path to compiled executable in /tmp folder (not so useful I think!). Is there a way to have the path of source itself?

Re: thisExePath and rdmd

2014-01-17 Thread Jacob Carlborg
On 2014-01-17 10:23, Andrea Fontana wrote: thisExePath returns the full path of the current executable. If I run something like ./mysource.d (using rdmd shebang) it returns the full path to compiled executable in /tmp folder (not so useful I think!). Is there a way to have the path of source

Re: thisExePath and rdmd

2014-01-17 Thread Andrea Fontana
Hmm I thought It can be done reading __FILE__ at compile-time, but it gives me just the relative path. Recent topic here: http://forum.dlang.org/thread/meuyppazxkrjcbgmk...@forum.dlang.org On Friday, 17 January 2014 at 09:29:48 UTC, Jacob Carlborg wrote: On 2014-01-17 10:23, Andrea Fontana

Re: thisExePath and rdmd

2014-01-17 Thread Jacob Carlborg
On 2014-01-17 10:50, Andrea Fontana wrote: Hmm I thought It can be done reading __FILE__ at compile-time, but it gives me just the relative path. Right, forgot about __FILE__. -- /Jacob Carlborg

Re: Associative array literal is non-constant?

2014-01-17 Thread pplantinga
On Saturday, 4 February 2012 at 06:45:08 UTC, H. S. Teoh wrote: On Fri, Feb 03, 2012 at 10:18:18PM -0800, H. S. Teoh wrote: Why does the following code give a compiler error? static int[string] table = [abc:1, def:2, ghi:3]; Error message is: prog.d:3: Error: non-constant expression

Re: errors with filesystem operations

2014-01-17 Thread Hugo Florentino
On Fri, 17 Jan 2014 07:07:35 +, Kagamin wrote: Does it fail for that one directory only or for any directory? Interesting question. I would have to do more tests with odd names, but apparently both remove() and rename() have problems with directories with a blank name. Curiously, moving

Re: errors with filesystem operations

2014-01-17 Thread Kagamin
I only noticed that rename uses MOVEFILE_REPLACE_EXISTING flag, which can't be used with directories. Are you sure remove fails too? If rename throws, remove is not called in your code.

Re: thisExePath and rdmd

2014-01-17 Thread Andrea Fontana
On Friday, 17 January 2014 at 10:48:33 UTC, Jacob Carlborg wrote: On 2014-01-17 10:50, Andrea Fontana wrote: Hmm I thought It can be done reading __FILE__ at compile-time, but it gives me just the relative path. Right, forgot about __FILE__. I think it would be useful to put full path on

Re: thisExePath and rdmd

2014-01-17 Thread Jacob Carlborg
On 2014-01-17 15:29, Andrea Fontana wrote: I think it would be useful to put full path on __FILE__ or to add another constant. Anyone? I agree. Probably safest to add a new constant, to avoid breaking code. -- /Jacob Carlborg

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread H. S. Teoh
On Fri, Jan 17, 2014 at 08:56:18AM +0100, Jacob Carlborg wrote: On 2014-01-16 21:26, Gary Willoughby wrote: What i would like to achieve is to dynamically assign and retrieve properties without declaring them first. For example: class T { public this() { this.foo =

Re: std.prelude vs core library

2014-01-17 Thread Sean Kelly
Another small reason is to enforce decoupling between required code and the rest of the library. Back when Phobos was all one library, half the library was compiled into every program. The runtime writes to stderr, the IO package relies on other modules... Kind of like what happens now if you

Re: package.d imports

2014-01-17 Thread Colden Cullen
On Thursday, 16 January 2014 at 15:46:01 UTC, Lemonfiend wrote: The following behavior seems odd to me. Could anyone explain why it works as it does? (Does package.d have a page on dlang.org?) --- main.d module main; void main() { test1(); test2(); } void test1() {

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread Gary Willoughby
On Friday, 17 January 2014 at 15:56:46 UTC, H. S. Teoh wrote: Couldn't you just return a Variant? I thought this is what Variants are made for. T Yes but then i would need to coerce it to get it's underlying type.

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread H. S. Teoh
On Fri, Jan 17, 2014 at 05:29:14PM +, Gary Willoughby wrote: On Friday, 17 January 2014 at 15:56:46 UTC, H. S. Teoh wrote: Couldn't you just return a Variant? I thought this is what Variants are made for. T Yes but then i would need to coerce it to get it's underlying type. But

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread Gary Willoughby
On Friday, 17 January 2014 at 17:50:54 UTC, H. S. Teoh wrote: On Fri, Jan 17, 2014 at 05:29:14PM +, Gary Willoughby wrote: On Friday, 17 January 2014 at 15:56:46 UTC, H. S. Teoh wrote: Couldn't you just return a Variant? I thought this is what Variants are made for. T Yes but then i

Re: Is continuously seeding a random number generator performance intensive?

2014-01-17 Thread Jeroen Bollen
On Wednesday, 15 January 2014 at 21:00:57 UTC, Jeroen Bollen wrote: How do you correctly create a MersenneTwisterEngine with a ulong as seed? This question still isn't answered by the way.

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread H. S. Teoh
On Fri, Jan 17, 2014 at 06:49:25PM +, Gary Willoughby wrote: [...] In the example in my original post the types are known at compile time but they are different between properties. I wondered if there was a solution to storing and retrieving while preserving the original type via

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread H. S. Teoh
On Fri, Jan 17, 2014 at 07:08:54PM +, Tobias Pankrath wrote: I can store properties of type A, B and C but when i retrieve them they all come back as A because of array covariance. I wonder if there is a way of casting them automagically to the correct type. So you basically want to

Re: package.d imports

2014-01-17 Thread Lemonfiend
I think this is what you are looking for: http://dlang.org/changelog.html#import_package What an odd place to put it.. Too bad, it doesn't mention anything about calling the functions like in my example, and why some do/don't work. I'd hoped for more.

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread Jacob Carlborg
On 2014-01-17 18:49, H. S. Teoh wrote: Now I'm not sure if Variant allows assignment to a static type, but in theory this should be possible: // assume d.abc returns a Variant int x = d.abc; // will assert if d.abc doesn't hold an int at runtime It doesn't work. Variant

Multiple while-loops parallelism

2014-01-17 Thread Mineko
Today I'm asking a more theoretical question, since I can't quite grasp this one too well. Let's say I want 3 while-loops running in parallel, without getting in the way of each other, how would I do that? With std.parallel of course, but that's where I get confused, perhaps someone could

Re: Multiple while-loops parallelism

2014-01-17 Thread Stanislav Blinov
On Friday, 17 January 2014 at 21:07:46 UTC, Mineko wrote: Let's say I want 3 while-loops running in parallel, without getting in the way of each other, how would I do that? On the same set of data? That's optimistic if one of the loops writes :) Otherwise, you could just create three tasks,

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread H. S. Teoh
On Fri, Jan 17, 2014 at 09:08:50PM +0100, Jacob Carlborg wrote: On 2014-01-17 18:49, H. S. Teoh wrote: Now I'm not sure if Variant allows assignment to a static type, but in theory this should be possible: // assume d.abc returns a Variant int x = d.abc; // will assert if d.abc

Re: Multiple while-loops parallelism

2014-01-17 Thread Kelet
On Friday, 17 January 2014 at 21:07:46 UTC, Mineko wrote: Today I'm asking a more theoretical question, since I can't quite grasp this one too well. Let's say I want 3 while-loops running in parallel, without getting in the way of each other, how would I do that? With std.parallel of

Re: Is it possible to store properties via opDispatch using tuples?

2014-01-17 Thread Jacob Carlborg
On 2014-01-17 22:14, H. S. Teoh wrote: Is that because D doesn't have implicit casting via opCast? -- because, conceivably, if x = d.abc; gets lowered to x = d.opCast!(typeof(x))(d.abc); then the above can be made to work. I don't know, maybe. -- /Jacob

Re: errors with filesystem operations

2014-01-17 Thread Hugo Florentino
On Fri, 17 Jan 2014 13:10:00 +, Kagamin wrote: I only noticed that rename uses MOVEFILE_REPLACE_EXISTING flag, which can't be used with directories. Are you sure remove fails too? If rename throws, remove is not called in your code. Well, as a matter of fact I did try to use remove