Re: Need help in templates

2011-03-24 Thread Ali Çehreli
On 03/24/2011 10:18 PM, Ishan Thilina wrote: > Hi, > > I'm still new to D. I tried to implement a stack using templates. But I get an > "Access Violation" error when I try to run a test on the stack that I made.The > source code is attached with this mail. Can somebody please point out the > er

Re: Need help in templates

2011-03-24 Thread Simen kjaeraas
On Fri, 25 Mar 2011 06:18:21 +0100, Ishan Thilina wrote: Hi, I'm still new to D. I tried to implement a stack using templates. But I get an "Access Violation" error when I try to run a test on the stack that I made.The source code is attached with this mail. Can somebody please point ou

Need help in templates

2011-03-24 Thread Ishan Thilina
Hi, I'm still new to D. I tried to implement a stack using templates. But I get an "Access Violation" error when I try to run a test on the stack that I made.The source code is attached with this mail. Can somebody please point out the error of this code? begin 644 main.d M;6]D=6QE(&UA:6X[#0H-"FEM

Re: Little quiz

2011-03-24 Thread Jesse Phillips
bearophile Wrote: > A little quiz for people here: guess the output of this little D2 program (it > compiles correctly and doesn't crash at run time, so it's a fair question): > > > import std.typecons: tuple; > import std.c.stdio: printf; > > auto foo() { > printf("foo\n"); > return t

Re: Little quiz

2011-03-24 Thread spir
On 03/25/2011 01:50 AM, bearophile wrote: A little quiz for people here: guess the output of this little D2 program (it compiles correctly and doesn't crash at run time, so it's a fair question): import std.typecons: tuple; import std.c.stdio: printf; auto foo() { printf("foo\n"); r

Little quiz

2011-03-24 Thread bearophile
A little quiz for people here: guess the output of this little D2 program (it compiles correctly and doesn't crash at run time, so it's a fair question): import std.typecons: tuple; import std.c.stdio: printf; auto foo() { printf("foo\n"); return tuple(1, 2); } void main() { foreac

Re: Bug in tuple comparison?

2011-03-24 Thread bearophile
> I agree. The second reduction I've written seems fit for Bugzila. http://d.puremagic.com/issues/show_bug.cgi?id=5783

Re: Using D libs in C

2011-03-24 Thread Dainius (GreatEmerald)
Hmm... Spent a few hours trying to figure out how to update GCC and all to conform to the requirements for 2.0.52, and at seems that it compiles my small test program just fine, but it fails on compiling the main project for some reason. And the linker outputs half-scrambled things. Anyway, here's

Re: Bug w/tuple of custom types?

2011-03-24 Thread Steven Schveighoffer
On Wed, 23 Mar 2011 16:14:55 -0400, bearophile wrote: Magnus Lie Hetland: Any way to do that without (to be deprecated) typedef? At the moment with a struct that contains an "alias this", I presume... And the alias this must point to a getter property to avoid the problem of implicitl

Re: Bug in tuple comparison?

2011-03-24 Thread bearophile
Jonathan M Davis: > Regardless, this _is_ a bug. I agree. The second reduction I've written seems fit for Bugzila. Bye, bearophile

Re: Bug in tuple comparison?

2011-03-24 Thread Jonathan M Davis
> On 2011-03-24 18:25:30 +0100, bearophile said: > > Magnus Lie Hetland: > >> I guess this is getting old by now ... but I've come across yet another > >> bug :-> > > > > The out(result) turns the result into a const, > > Riiight! Yes, I've seen that it's const, and (naughtily) cast away the > co

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-24 Thread Trass3r
Is there a copy of the official D grammar somewhere online? I wrote a lexer for my Compiler class and would love to try and apply it to another grammar. The official D grammar is spread among the specification. But I recall that someone compiled a complete grammar for D1 some time ago.

Re: Bug in tuple comparison?

2011-03-24 Thread Magnus Lie Hetland
On 2011-03-24 18:25:30 +0100, bearophile said: Magnus Lie Hetland: I guess this is getting old by now ... but I've come across yet another bug :-> The out(result) turns the result into a const, Riiight! Yes, I've seen that it's const, and (naughtily) cast away the constness (without modif

Re: Bug in tuple comparison?

2011-03-24 Thread bearophile
Magnus Lie Hetland: > I guess this is getting old by now ... but I've come across yet another bug > :-> The out(result) turns the result into a const, this causes some troubles you see in this simpler program: import std.typecons; void main() { alias Tuple!(int) T; const T t = T();

Bug in tuple comparison?

2011-03-24 Thread Magnus Lie Hetland
I guess this is getting old by now ... but I've come across yet another bug :-> This one is a bit obscure, and deals with comparing tuples in contracts. It seems that some type information about the result is lost when entering an out-block, or something. At least, DMD (2.052, OS X) is unable

Re: Using D libs in C

2011-03-24 Thread Jesse Phillips
Dainius (GreatEmerald) Wrote: > Ah, including pthread indeed works, but now I've run into another > problem related to Linux and architecture. I want to use D for my > program that also uses things like SDL and Lua. Earlier when I > compiled it, I always did so with 64-bit libraries. But D is so f

Re: C++ to D: mutable

2011-03-24 Thread Jonathan M Davis
> Caligo Wrote: > > Greetings, > > > > I have a C++ class that I would like to rewrite it in D. The class > > has members that are declared as 'mutable'. How do I achieve the same > > effect in D? if not, what is recommended? > > const int a=0; > *cast(int*)&a=1; There are so many reasons to c

Re: Using D libs in C

2011-03-24 Thread Dainius (GreatEmerald)
Ah, including pthread indeed works, but now I've run into another problem related to Linux and architecture. I want to use D for my program that also uses things like SDL and Lua. Earlier when I compiled it, I always did so with 64-bit libraries. But D is so far only in 32-bits, thus when compiling

Re: C++ to D: mutable

2011-03-24 Thread Kagamin
Caligo Wrote: > Greetings, > > I have a C++ class that I would like to rewrite it in D. The class > has members that are declared as 'mutable'. How do I achieve the same > effect in D? if not, what is recommended? const int a=0; *cast(int*)&a=1;

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-24 Thread spir
On 03/24/2011 08:53 AM, Alexey Prokhin wrote: Currently, as far as I know, there are only two lexers and two parsers for D: the C++ front end which dmd, gdc, and ldc use and the D front end which ddmd uses and which is based on the C++ front end. Both of those are under the GPL (which makes th

Re: Want to help DMD bugfixing? Write a simple utility.

2011-03-24 Thread Alexey Prokhin
> Currently, as far as I know, there are only two lexers and two parsers for > D: the C++ front end which dmd, gdc, and ldc use and the D front end which > ddmd uses and which is based on the C++ front end. Both of those are under > the GPL (which makes them useless for a lot of stuff) and both of

Re: C++ to D: mutable

2011-03-24 Thread Bekenn
On 3/24/2011 12:23 AM, Caligo wrote: Greetings, I have a C++ class that I would like to rewrite it in D. The class has members that are declared as 'mutable'. How do I achieve the same effect in D? if not, what is recommended? You don't. Specific recommendations would depend on how the clas

Re: C++ to D: mutable

2011-03-24 Thread Jonathan M Davis
> Greetings, > > I have a C++ class that I would like to rewrite it in D. The class > has members that are declared as 'mutable'. How do I achieve the same > effect in D? if not, what is recommended? You don't - or at least it's generally inadvisable to try. Unlike C++, const in D is transitiv

C++ to D: mutable

2011-03-24 Thread Caligo
Greetings, I have a C++ class that I would like to rewrite it in D. The class has members that are declared as 'mutable'. How do I achieve the same effect in D? if not, what is recommended?

Re: Bug w/tuple of custom types?

2011-03-24 Thread Bekenn
On 3/23/2011 12:45 PM, Magnus Lie Hetland wrote: Any way to do that without (to be deprecated) typedef? Nothing pretty, at least not yet. bearophile's suggestion is about as close as you can get right now.