Template return values?

2012-12-03 Thread Era Scarecrow
A thought's been going through my head for a while now. I wonder about template return values. Function signatures are usually the inputs and NOT the return type. However for writing a variant type could be so very useful. So unless I've misunderstood, this doesn't work (but it would be cool i

Re: How to import modules?

2012-12-03 Thread Mike Parker
On Tuesday, 4 December 2012 at 04:31:40 UTC, js.mdnq wrote: I created a .d file having a class with the modules tag at the top and everything public. I put it in a dir and used the -I flag to include the path. When I import the file I get an undefined method. 1. Do I need to compile the .d fil

How to import modules?

2012-12-03 Thread js.mdnq
I created a .d file having a class with the modules tag at the top and everything public. I put it in a dir and used the -I flag to include the path. When I import the file I get an undefined method. 1. Do I need to compile the .d file into a lib or can I just import the .d and have it included d

Re: Array indexing

2012-12-03 Thread Ali Çehreli
On 12/03/2012 04:43 PM, js.mdnq wrote: When accessing an element outside a dynamic array I get an exception. I thought in D arrays will automatically expand themselves? If not, how do I add an element to an array? int[] arr = new int[1]; arr[1] = 34; // exception Another option is to modify

Re: Array indexing

2012-12-03 Thread bearophile
js.mdnq: When accessing an element outside a dynamic array I get an exception. I thought in D arrays will automatically expand themselves? D dynamic arrays don't expand themselves "on demand" on array access, it's not efficient (and I think it's not a very clean operation, despite some lan

Re: Most elegant representation of a card's rank

2012-12-03 Thread bearophile
deed: And using enum Rank { two, three, four, ... , K, A } is not elegant. But it's strongly typed, so it's safere. It's my preferred solution for a problem like this. I'd like to be able to call foo(Rank rank) with foo(3) and foo(Q). Then use module level compile-time constant... Bye,

Re: Array indexing

2012-12-03 Thread Adam D. Ruppe
Try arr ~= 33; the ~= operator means append to. You can also do auto a = [1,2] ~ [3,4]; which would give [1,2,3,4]

Array indexing

2012-12-03 Thread js.mdnq
When accessing an element outside a dynamic array I get an exception. I thought in D arrays will automatically expand themselves? If not, how do I add an element to an array? int[] arr = new int[1]; arr[1] = 34; // exception If I change this to int[] arr = new int[2]; arr[1] = 34; Then it w

Re: Most elegant representation of a card's rank

2012-12-03 Thread deed
On Monday, 3 December 2012 at 23:42:38 UTC, bearophile wrote: deed: How is a playing card's rank represented most elegantly in code? Maybe with an enum? enum Card { J, Q, ...} If you have to store many of them then maybe giving them a size of one byte is better: enum Card : ubyte { Ace,

Re: std.bigint: BigInt conversion

2012-12-03 Thread bearophile
novice2: I hope, this changes will be included in phobos in future. Sometimes hoping isn't enough. If you have a need that youi think should be in Phobos, then I think you should ask for it in Bugzilla. Asking isn't equal to someone actually implementing it, but in this early stage of the l

Re: Most elegant representation of a card's rank

2012-12-03 Thread bearophile
deed: How is a playing card's rank represented most elegantly in code? Maybe with an enum? enum Card { J, Q, ...} If you have to store many of them then maybe giving them a size of one byte is better: enum Card : ubyte { Ace, Two, ..., Q, ...} Bye, bearophile

Most elegant representation of a card's rank

2012-12-03 Thread deed
How is a playing card's rank represented most elegantly in code? * Should be a customized uint/an own type representing uints in the range of 2 through 14. * void foo(Rank rank) { } // Accepts only the valid range foo(0); // Error foo(2); // Ok foo(10); // Ok alias J 11; alias Q 1

Re: DLL Injection

2012-12-03 Thread maarten van damme
Yes, that was the problem :p I have no idea about mcvr71, maybe because of std.process but that isn't that huge a concern

Introspection: TLS and __gshared variables

2012-12-03 Thread Benjamin Thaut
I'm currently playing around with D's compile time introspection and I'm trying to do the following: 1. Detect if a member is static 2. Detect if a member is __gshared 3. Get the TLS offset of a static variable (at compile time...) I would be glad if anyone could help me with one ore multiple o

Re: std.bigint: BigInt conversion

2012-12-03 Thread novice2
Big thank you. I hope, this changes will be included in phobos in future.

Re: DLL Injection

2012-12-03 Thread s0beit
On Monday, 3 December 2012 at 11:08:34 UTC, maarten van damme wrote: Strangely, the main in my dll is getting executed multiple times and msvcr71.dll gets injected too. Is this normal? mcvcr71.dll is probably loaded by your library, I don't know if D uses visual studio dependencies... one wou

Re: DLL Injection

2012-12-03 Thread maarten van damme
Strangely, the main in my dll is getting executed multiple times and msvcr71.dll gets injected too. Is this normal? 2012/12/3 s0beit : > On Sunday, 2 December 2012 at 22:30:56 UTC, maarten van damme wrote: >> >> Thanks, interesting blog :) >> >> 2012/12/2 s0beit : >>> >>> Alright, I was finally ab