Re: Need help in templates

2011-03-25 Thread Ishan Thilina
@Simen: Thanks a lot, That solved the problem :). @Ali: :s I'm confused, some of the readers has got the attachment correctly :s

Re: C++ to D: mutable

2011-03-25 Thread Kagamin
Jonathan M Davis Wrote: > > const int a=0; > > *cast(int*)&a=1; > > There are so many reasons to cringe at that. Taking the address of a local > variable is generally very dangerous. As long as the pointer doesn't escape > and exist beyond the life the variable, then you're okay, but you often

Re: Need help in templates

2011-03-25 Thread Regan Heath
On Fri, 25 Mar 2011 05:51:11 -, Ali Çehreli wrote: 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

Re: Little quiz

2011-03-25 Thread Jacob Carlborg
On 2011-03-25 01:50, 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"); retu

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

2011-03-25 Thread Regan Heath
On Wed, 23 Mar 2011 21:16:02 -, Jonathan M Davis wrote: There are tasks for which you need to be able to lex and parse D code. To 100% correctly remove unit tests would be one such task. Is that last bit true? You definitely need to be able to lex it, but instead of actually parsing i

Re: Little quiz

2011-03-25 Thread bearophile
Jacob Carlborg: > I would guess it prints the values of all the fields in the struct > returned by "tuple". That was of course my purpose, because tuples are a way to implement multiple return values, and in some situations I want to print all the items of such return tuple, on separated lines

Re: Need help in templates

2011-03-25 Thread spir
On 03/25/2011 06:18 AM, 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 error of this c

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

2011-03-25 Thread spir
On 03/25/2011 12:08 PM, Regan Heath wrote: On Wed, 23 Mar 2011 21:16:02 -, Jonathan M Davis wrote: There are tasks for which you need to be able to lex and parse D code. To 100% correctly remove unit tests would be one such task. Is that last bit true? You definitely need to be able to l

Re: Using D libs in C

2011-03-25 Thread Dainius (GreatEmerald)
Oh, I found the problem... It's just me forgetting that my library has to go before phobos to compile it. So right now it works perfectly! Thanks!

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

2011-03-25 Thread Don
spir wrote: On 03/25/2011 12:08 PM, Regan Heath wrote: On Wed, 23 Mar 2011 21:16:02 -, Jonathan M Davis wrote: There are tasks for which you need to be able to lex and parse D code. To 100% correctly remove unit tests would be one such task. Is that last bit true? You definitely need to

Re: Need help in templates

2011-03-25 Thread Jesse Phillips
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 > error of this code? In gene

Re: Little quiz

2011-03-25 Thread Jacob Carlborg
On 2011-03-25 12:32, bearophile wrote: Jacob Carlborg: I would guess it prints the values of all the fields in the struct returned by "tuple". That was of course my purpose, because tuples are a way to implement multiple return values, and in some situations I want to print all the items of

Re: C++ to D: mutable

2011-03-25 Thread Jonathan M Davis
> Jonathan M Davis Wrote: > > > const int a=0; > > > *cast(int*)&a=1; > > > > There are so many reasons to cringe at that. Taking the address of a > > local variable is generally very dangerous. As long as the pointer > > doesn't escape and exist beyond the life the variable, then you're okay, > >

Re: Little quiz

2011-03-25 Thread Kagamin
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

clear()

2011-03-25 Thread Dr.Smith
To empty many arrays of various types, rather than: clear(arr1); clear(arr2); ... clear(arrN); is there something like: clear(ALL); Also, after "clear(arr)", will "arr ~= value" assign starting from element 0?

Re: clear()

2011-03-25 Thread Steven Schveighoffer
On Fri, 25 Mar 2011 15:10:44 -0400, Dr.Smith wrote: To empty many arrays of various types, rather than: clear(arr1); clear(arr2); ... clear(arrN); is there something like: clear(ALL); Not sure what this would do. Clear all arrays? That isn't possible. Also, after "clear(arr)", will "arr

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

2011-03-25 Thread Nick Sabalausky
"Regan Heath" wrote in message news:op.vswbv8qj54x...@puck.auriga.bhead.co.uk... > On Wed, 23 Mar 2011 21:16:02 -, Jonathan M Davis > wrote: >> There are tasks for which you need to be able to lex and parse D code. >> To 100% correctly remove unit tests would be one such task. > > Is that

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

2011-03-25 Thread Nick Sabalausky
"Alexey Prokhin" wrote in message news:mailman.2713.1300954193.4748.digitalmars-d-le...@puremagic.com... >> 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 ba

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

2011-03-25 Thread Nick Sabalausky
"Andrej Mitrovic" wrote in message news:mailman.2696.1300895928.4748.digitalmars-d-le...@puremagic.com... > On 3/23/11, Jonathan M Davis wrote: >> That would require a full-blown D lexer and parser. >> >> - Jonathan M Davis >> > Isn't DDMD written in D? I'm not sure about how finished it is thou

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

2011-03-25 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:imivp7$2fu$1...@digitalmars.com... > "Alexey Prokhin" wrote in message > news:mailman.2713.1300954193.4748.digitalmars-d-le...@puremagic.com... >>> Currently, as far as I know, there are only two lexers and two parsers >>> for >>> D: the C++ front end wh

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

2011-03-25 Thread Nick Sabalausky
"Jonathan M Davis" wrote in message news:mailman.2700.1300915109.4748.digitalmars-d-le...@puremagic.com... >> On 3/23/11, Jonathan M Davis wrote: >> > That would require a full-blown D lexer and parser. >> > >> > - Jonathan M Davis >> >> Isn't DDMD written in D? I'm not sure about how finished i

inline functions

2011-03-25 Thread Caligo
T[3] data; T dot(const ref Vector o){ return data[0] * o.data[0] + data[1] * o.data[1] + data[2] * o.data[2]; } T LengthSquared_Fast(){ return data[0] * data[0] + data[1] * data[1] + data[2] * data[2]; } T LengthSquared_Slow(){ return dot(this); } The faster LengthSquared() is twice as fast

Re: inline functions

2011-03-25 Thread Jonathan M Davis
On 2011-03-25 19:04, Caligo wrote: > T[3] data; > > T dot(const ref Vector o){ > return data[0] * o.data[0] + data[1] * o.data[1] + data[2] * o.data[2]; > } > > T LengthSquared_Fast(){ return data[0] * data[0] + data[1] * data[1] + > data[2] * data[2]; } > T LengthSquared_Slow(){ return dot(t

Re: inline functions

2011-03-25 Thread Caligo
On Fri, Mar 25, 2011 at 10:49 PM, Jonathan M Davis wrote: > On 2011-03-25 19:04, Caligo wrote: >> T[3] data; >> >> T dot(const ref Vector o){ >>     return data[0] * o.data[0] + data[1] * o.data[1] + data[2] * o.data[2]; >> } >> >> T LengthSquared_Fast(){ return data[0] * data[0] + data[1] * data[

Re: inline functions

2011-03-25 Thread Jonathan M Davis
On 2011-03-25 21:21, Caligo wrote: > On Fri, Mar 25, 2011 at 10:49 PM, Jonathan M Davis wrote: > > On 2011-03-25 19:04, Caligo wrote: > >> T[3] data; > >> > >> T dot(const ref Vector o){ > >> return data[0] * o.data[0] + data[1] * o.data[1] + data[2] * > >> o.data[2]; } > >> > >> T LengthSq

Re: Need help in templates

2011-03-25 Thread Bekenn
On 3/25/2011 3:34 AM, Regan Heath wrote: FYI.. that's uuencoded data: http://en.wikipedia.org/wiki/Uuencoding it's one of the older style encodings used by NNTP. Most readers should support it. Oddly enough, Thunderbird is one that doesn't.