Re: need help convert c code

2009-07-16 Thread D. Reeds
Robert Fraser Wrote: > D. Reeds wrote: > > can anybody help me translate this c code into d, im using D1+tango combo. > > i'm new to D and got stucked on multi-dimension array part. > > > > int levenshtein_distance(char *s,char*t) > > //Compute levenshtein distance between s and t > > { > > /

Re: need help convert c code

2009-07-16 Thread D. Reeds
Robert Fraser Wrote: > D. Reeds wrote: > > can anybody help me translate this c code into d, im using D1+tango combo. > > i'm new to D and got stucked on multi-dimension array part. > > > > int levenshtein_distance(char *s,char*t) > > //Compute levenshtein distance between s and t > > { > > /

Re: need help convert c code

2009-07-16 Thread Robert Fraser
D. Reeds wrote: can anybody help me translate this c code into d, im using D1+tango combo. i'm new to D and got stucked on multi-dimension array part. int levenshtein_distance(char *s,char*t) //Compute levenshtein distance between s and t { //Step 1 int k,i,j,n,m,cost,*d,distance; n=strle

need help convert c code

2009-07-16 Thread D. Reeds
can anybody help me translate this c code into d, im using D1+tango combo. i'm new to D and got stucked on multi-dimension array part. int levenshtein_distance(char *s,char*t) //Compute levenshtein distance between s and t { //Step 1 int k,i,j,n,m,cost,*d,distance; n=strlen(s); m=strlen

Re: stack trace hack for recent Phobos?

2009-07-16 Thread Robert Fraser
Trass3r wrote: Robert Fraser schrieb: Windows or Unix? Currently I only need Windoze, but knowing the linux situation wouldn't be bad either. There's no Windows stack trace that works with the newest Phobos AFAIK, however if you're using D2, you could probably copy Tango's stacktrace pret

Re: Why can't return an object instance by ref?

2009-07-16 Thread Jarrett Billingsley
On Thu, Jul 16, 2009 at 9:47 PM, Sam Hu wrote: > Hi, > > With below code: > class A > { > } > class B > { > public: > ref A createA() //  q2:without type name A is also OK? > { >    return new A;//q1 > } > > } > My questions are: > q1.why this can't work? Because 'new A' is not an lvalue. Why do

Why can't return an object instance by ref?

2009-07-16 Thread Sam Hu
Hi, With below code: class A { } class B { public: ref A createA() // q2:without type name A is also OK? { return new A;//q1 } } My questions are: q1.why this can't work? q2.I can understand below code works: A createA(){return new A;} but why this one also works? ref createA(){return new

Re: stack trace hack for recent Phobos?

2009-07-16 Thread Trass3r
Robert Fraser schrieb: Windows or Unix? Currently I only need Windoze, but knowing the linux situation wouldn't be bad either.

Re: stack trace hack for recent Phobos?

2009-07-16 Thread Robert Fraser
Trass3r wrote: Is there a way to get a stacktrace when an exception occurs in recent Phobos versions? Windows or Unix?

Re: closures

2009-07-16 Thread Steven Schveighoffer
On Thu, 16 Jul 2009 14:56:28 -0400, Jarrett Billingsley wrote: On Thu, Jul 16, 2009 at 2:22 PM, Steven Schveighoffer wrote: What about syntax to force closure behavior (on or off)?  Not that I have any to suggest, but if the compiler is going to remain ignorant about escape analysis, th

Re: closures

2009-07-16 Thread Jarrett Billingsley
On Thu, Jul 16, 2009 at 2:33 PM, bearophile wrote: > Jens: >>  // On dmd v2.029, linux build, this... >>   call(makedelegate1()); // ...works: 27 >>   call(makedelegate2()); // ...works: 7 >>   call(makedelegate3()); // ...doesn't work: 134518855 >>   call(makedelegate4()); // ...doesn't work: 1345

Re: closures

2009-07-16 Thread Jarrett Billingsley
On Thu, Jul 16, 2009 at 2:22 PM, Steven Schveighoffer wrote: > > What about syntax to force closure behavior (on or off)?  Not that I have > any to suggest, but if the compiler is going to remain ignorant about escape > analysis, then we should be able to supply the intelligence, and hacking an > e

Re: closures

2009-07-16 Thread bearophile
Jens: > // On dmd v2.029, linux build, this... > call(makedelegate1()); // ...works: 27 > call(makedelegate2()); // ...works: 7 > call(makedelegate3()); // ...doesn't work: 134518855 > call(makedelegate4()); // ...doesn't work: 134518947 > Foo f; > call(&f.bar); // ...works: 7 I have

Re: closures

2009-07-16 Thread Steven Schveighoffer
On Thu, 16 Jul 2009 13:34:27 -0400, Jarrett Billingsley wrote: On Thu, Jul 16, 2009 at 1:24 PM, BCS wrote: Reply to Jarrett, I think what's going on here is that the compiler will *only* allocate closures for nested functions. However allocating a closure for a delegate of a value object w

Re: closures

2009-07-16 Thread Jarrett Billingsley
On Thu, Jul 16, 2009 at 1:24 PM, BCS wrote: > Reply to Jarrett, > >> I think what's going on here is that the compiler will *only* allocate >> closures for nested functions. However allocating a closure for a >> delegate of a value object would be a nice addition. >> > > This will quickly devolve i

Re: closures

2009-07-16 Thread BCS
Reply to Jarrett, I think what's going on here is that the compiler will *only* allocate closures for nested functions. However allocating a closure for a delegate of a value object would be a nice addition. This will quickly devolve into the general escape analysts problem and here there be

stack trace hack for recent Phobos?

2009-07-16 Thread Trass3r
Is there a way to get a stacktrace when an exception occurs in recent Phobos versions?

Re: closures

2009-07-16 Thread Jarrett Billingsley
On Thu, Jul 16, 2009 at 8:02 AM, Jens wrote: > Hello there, > > I'm new to D and experimenting with closures. I know the basics of how > compilers translate things, especially in C++. So I appreciate the difficulty > of implementing closures correctly and been wondering if it really works. I > f

closures

2009-07-16 Thread Jens
Hello there, I'm new to D and experimenting with closures. I know the basics of how compilers translate things, especially in C++. So I appreciate the difficulty of implementing closures correctly and been wondering if it really works. I found a place where dmd 2 appears to fail, but I don't kn