Re: learn D & TDPL

2012-01-23 Thread Gour
On Mon, 23 Jan 2012 12:37:45 -0700 Brad Anderson wrote: > This is a very helpful post, Jonathan. I think the documentation > could do with a "Changes and additions since TDPL" section with stuff > like this so users aren't surprised. Users could easily mistake > changes for bugs without these b

Re: KeyType, ValueType traits for hashes

2012-01-23 Thread Andrej Mitrovic
The only issue I have with this is the isAssociativeArray constraint. That template uses __traits(isAssociativeArray, T), which returns FALSE for DCollection's HashMap type. It would be a shame if you couldn't define a drop-in replacement to builtin hashes with your own implementation, seeing as su

Re: KeyType, ValueType traits for hashes

2012-01-23 Thread Andrej Mitrovic
But I did implement them poorly, this is better: import std.traits; template KeyType(AA) if (isAssociativeArray!AA) { static if (is(AA V : V[K], K)) { alias K KeyType; } } template ValueType(AA) if (isAssociativeArray!AA) { static if (is(AA V : V[U], U)) {

Re: learn D & TDPL

2012-01-23 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.659.1327175391.16222.digitalmars-d-le...@puremagic.com... > It's partially available. It just isn't fully implemented, and I don't > know > what's missing from it. And I have no idea when it will be fully > implemented. > You can certainly use it

Re: learn D & TDPL

2012-01-23 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.659.1327175391.16222.digitalmars-d-le...@puremagic.com... > > It's partially available. It just isn't fully implemented, and I don't > know > what's missing from it. And I have no idea when it will be fully > implemented. > You can certainly use

floating-WTF

2012-01-23 Thread Caligo
alias double Real; //alias float Real; // simple linear interpolation; I partitioned the internals to help me figure out what was happening. Real lerp(Real t, Real a, Real b){ Real s1 = (1.0 - t) * a; Real s2 = t * b; Real rt1 = s1 + s2; Real rt2 = ((1.0 - t) * a) + (t * b); writefln("t=

Re: MySQL

2012-01-23 Thread Mike Parker
On 1/23/2012 11:29 AM, Mars wrote: On Sunday, 22 January 2012 at 23:23:23 UTC, Kapps wrote: 2) Create the binding functions using extern(System). Oh man... that was the problem. The file I used was using extern(C). Thought that was okay, it's a C lib after all. Thank you! Mars A number of l

Re: KeyType, ValueType traits for hashes

2012-01-23 Thread bearophile
Andrej Mitrovic: > I haven't found these in Phobos, so if they're really not in > std.traits or anywhere do you think I should make a pull request for > this? They are useful. Bye, bearophile

Re: Extend Enum

2012-01-23 Thread Ali Çehreli
On 01/23/2012 04:04 PM, Mars wrote: On Monday, 23 January 2012 at 22:48:02 UTC, Ali Çehreli wrote: If it makes sense, you can use version(x) blocks within the single enum definition, as opposed to putting version(x) outside. Could you give me an example, what that would look like? So far I coul

Re: Extend Enum

2012-01-23 Thread Mars
On Monday, 23 January 2012 at 22:48:02 UTC, Ali Çehreli wrote: If it makes sense, you can use version(x) blocks within the single enum definition, as opposed to putting version(x) outside. Could you give me an example, what that would look like? So far I couldn't find a way to use version insid

Re: Indexed foreach on struct?

2012-01-23 Thread Ali Çehreli
On 01/23/2012 03:27 PM, Matt Soucy wrote: > On 01/23/2012 04:28 PM, Ali Çehreli wrote: >> On 01/23/2012 12:32 PM, Matt Soucy wrote: >>> So I was messing around with some code I've been writing recently, and I >>> wanted to use a foreach on a struct as if it were an associative array. >> >> bearo

Re: Indexed foreach on struct?

2012-01-23 Thread Matt Soucy
On 01/23/2012 04:28 PM, Ali Çehreli wrote: On 01/23/2012 12:32 PM, Matt Soucy wrote: So I was messing around with some code I've been writing recently, and I wanted to use a foreach on a struct as if it were an associative array. bearophile and I had replied to your earlier post. Ali Eek, I'm

Re: Extend Enum

2012-01-23 Thread Ali Çehreli
On 01/23/2012 02:38 PM, Mars wrote: Hello everybody. I'd like to know if there's a way, to extend an Enum, based on version(). I have an Enum, that holds various values, but some are different, in other versions. So the alternative would be to define the Enum several times. version(x) { enum ex

KeyType, ValueType traits for hashes

2012-01-23 Thread Andrej Mitrovic
I haven't found these in Phobos, so if they're really not in std.traits or anywhere do you think I should make a pull request for this? import std.traits; template KeyType(T) if (isAssociativeArray!T) { alias typeof(T.keys()[0]) KeyType; } template ValueType(T) if (isAssociativeArray

Extend Enum

2012-01-23 Thread Mars
Hello everybody. I'd like to know if there's a way, to extend an Enum, based on version(). I have an Enum, that holds various values, but some are different, in other versions. So the alternative would be to define the Enum several times. version(x) { enum example { FOO = 1, BAR = 2, } } e

Re: Indexed foreach on struct?

2012-01-23 Thread H. S. Teoh
On Mon, Jan 23, 2012 at 01:26:44PM -0800, Ali Çehreli wrote: > On 01/23/2012 01:16 PM, H. S. Teoh wrote: [...] > > struct Test { > > int opApply(int delegate(ref int) dg) { > > auto ret = 0; > > for (auto i=0; ret==0&& i<5; i++) { > >

Re: Indexed foreach on struct?

2012-01-23 Thread H. S. Teoh
On Mon, Jan 23, 2012 at 01:16:29PM -0800, H. S. Teoh wrote: > On Mon, Jan 23, 2012 at 03:32:07PM -0500, Matt Soucy wrote: > > So I was messing around with some code I've been writing recently, > > and I wanted to use a foreach on a struct as if it were an > > associative array. The problem is, I ca

Re: Indexed foreach on struct?

2012-01-23 Thread Ali Çehreli
On 01/23/2012 12:32 PM, Matt Soucy wrote: So I was messing around with some code I've been writing recently, and I wanted to use a foreach on a struct as if it were an associative array. bearophile and I had replied to your earlier post. Ali

Re: Indexed foreach on struct?

2012-01-23 Thread Ali Çehreli
On 01/23/2012 01:16 PM, H. S. Teoh wrote: > On Mon, Jan 23, 2012 at 03:32:07PM -0500, Matt Soucy wrote: >> So I was messing around with some code I've been writing recently, >> and I wanted to use a foreach on a struct as if it were an >> associative array. The problem is, I can't find any informa

Re: Indexed foreach on struct?

2012-01-23 Thread H. S. Teoh
On Mon, Jan 23, 2012 at 03:32:07PM -0500, Matt Soucy wrote: > So I was messing around with some code I've been writing recently, > and I wanted to use a foreach on a struct as if it were an > associative array. The problem is, I can't find any information on > how to do that. [...] > I don't see an

Re: learn D & TDPL

2012-01-23 Thread Brad Anderson
On Sat, Jan 21, 2012 at 1:42 AM, Jonathan M Davis wrote: > On Saturday, January 21, 2012 09:11:52 Gour wrote: > > Hello! > > > > I'd like to re-start learning D (from scratch) using TDPL. > > > > However, several times I've encountered some message which says that > > there are some problems in le

Indexed foreach on struct?

2012-01-23 Thread Matt Soucy
So I was messing around with some code I've been writing recently, and I wanted to use a foreach on a struct as if it were an associative array. The problem is, I can't find any information on how to do that. I can't use something like "alias this", because the class I'm writing acts as a wrappe

Re: actors library?

2012-01-23 Thread Timon Gehr
On 01/23/2012 08:01 PM, Xan xan wrote: Hi. Is there any actors library in D. Spawn and etc is ok, but I want more high-level thing and actors it's the best I get, I think. I searched and nothing. I'm interested in D 2.0 or 1.0. Whatever! Thanks in advace, Xan. std.concurrency is an actors li

actors library?

2012-01-23 Thread Xan xan
Hi. Is there any actors library in D. Spawn and etc is ok, but I want more high-level thing and actors it's the best I get, I think. I searched and nothing. I'm interested in D 2.0 or 1.0. Whatever! Thanks in advace, Xan.

Re: for loop

2012-01-23 Thread Jonathan M Davis
On Monday, January 23, 2012 19:48:02 Timon Gehr wrote: > On 01/23/2012 07:06 PM, bearophile wrote: > > Ellery Newcomer: > >> void main(){ > >> > >> for ({int x=0; short y=0;} x< 10; x++, y++){ > >> } > >> > >> } > > > > I don't understand, is that a compiler bug? > > Aren't x and y in a sub-scop

Re: for loop

2012-01-23 Thread Timon Gehr
On 01/23/2012 07:06 PM, bearophile wrote: Ellery Newcomer: void main(){ for ({int x=0; short y=0;} x< 10; x++, y++){ } } I don't understand, is that a compiler bug? Aren't x and y in a sub-scope that ends before you use x and y? Bye, bearophile It is not a bug. ForSta

Re: for loop

2012-01-23 Thread Mantis
23.01.2012 20:06, bearophile пишет: Ellery Newcomer: void main(){ for ({int x=0; short y=0;} x< 10; x++, y++){ } } I don't understand, is that a compiler bug? Aren't x and y in a sub-scope that ends before you use x and y? Bye, bearophile According to specs, this is Bloc

Re: for loop

2012-01-23 Thread bearophile
Ellery Newcomer: > void main(){ > for ({int x=0; short y=0;} x < 10; x++, y++){ > } > } I don't understand, is that a compiler bug? Aren't x and y in a sub-scope that ends before you use x and y? Bye, bearophile

Re: for loop

2012-01-23 Thread Trass3r
void main(){ for ({int x=0; short y=0;} x < 10; x++, y++){ } } wtf?

Re: for loop

2012-01-23 Thread Ellery Newcomer
On 01/22/2012 11:37 AM, Zachary Lund wrote: This is an ugly solution (and I'm not 100% sure it's valid D) but: /+/ void main() { { short y = 0; int x = 0; for (; x < 10; ++x, ++y) { } } } /+/ raise you. void main(){ for ({int