Re: unit testing

2011-03-28 Thread Ishan Thilina
- Jonathan M Davis wrote: >LOL. Goodness no. They're done by hand. I'm currently reworking std.datetime's >unit tests, and it's very time consuming (since it's a large module with lots >of tests). I don't know how you'd get a framework to generate what I want >anyway. The fact that D has unit test

Re: Container access in std.container

2011-03-28 Thread Ishan Thilina
>Your environment looks wrong. Note that > >/usr/lib/gcc/x86_64-linux-gnu/4.3.5/../../../../include/d/4.3.5 > >is equivalent to > >/usr/include/d/4.3.5 I copied container.d to /usr/include/d/4.3.5/std . But the problem is still there :s

Re: Container access in std.container

2011-03-28 Thread Ishan Thilina
Steven wrote: >Your environment looks wrong. Note that > >/usr/lib/gcc/x86_64-linux-gnu/4.3.5/../../../../include/d/4.3.5 > >is equivalent to > >/usr/include/d/4.3.5 > >so I expect it can't find container.d Really sorry for being a burden, I'm new to D. How can I fix this Environment?

Re: Container access in std.container

2011-03-28 Thread Steven Wawryk
Your environment looks wrong. Note that /usr/lib/gcc/x86_64-linux-gnu/4.3.5/../../../../include/d/4.3.5 is equivalent to /usr/include/d/4.3.5 so I expect it can't find container.d On 29/03/11 04:54, Ishan Thilina wrote: I am using DGC due to the problems I'm witnessing with DMD. I tried a

Re: clear()

2011-03-28 Thread Simen kjaeraas
On Mon, 28 Mar 2011 16:57:17 +0200, Kai Meyer wrote: On 03/25/2011 01:10 PM, Dr.Smith wrote: To empty many arrays of various types, rather than: clear(arr1); clear(arr2); ... clear(arrN); is there something like: clear(ALL); No, but perhaps you can do a: foreach(a; ALL) a.clear() Tha

Re: Container access in std.container

2011-03-28 Thread Ishan Thilina
>I am using GDC due to the problems I'm witnessing with DMD. I tried a similar >approach. But the following error comes. > >" > >structures.d:4: Error: module container cannot read file 'std/container.d' >import path[0] = >/usr/lib/gcc/x86_64-linux-gnu/4.3.5/../../../../include/d/4.3.5/x86_64-linux

Re: Assertion failure: '!vthis->csym' on line 703 in file 'glue.c'

2011-03-28 Thread Don
nrgyzer wrote: Hey guys, I got "Assertion failure: '!vthis->csym' on line 703 in file 'glue.c'" after I add "LinkList!(uint) myList;" to my source file. I figured out that the same bug was already reported on http://lists.puremagic.com/ pipermail/digitalmars-d-bugs/2010-October/019237.html Ticke

Re: unit testing

2011-03-28 Thread Jonathan M Davis
On 2011-03-28 11:29, Ishan Thilina wrote: > @David: > > No, my question was not about running them,but on how that code was > generated. I thought they were auto generated using a unitest framework > :). Your answer clarifies everything. Thank you..! :-) LOL. Goodness no. They're done by hand. I'

Re: How do you use BinaryHeap with Array (or just make a growable heap)?

2011-03-28 Thread Magnus Lie Hetland
On 2011-03-28 20:24:55 +0200, Jonathan M Davis said: Well, Array definitely shouldn't be a random access range. The range for it (which you'd typically get by slicing it) would be random access, but the container itself isn't a range of any kind. Containers aren't ranges (barring the oddities of

Re: unit testing

2011-03-28 Thread Ishan Thilina
@David: No, my question was not about running them,but on how that code was generated. I thought they were auto generated using a unitest framework :). Your answer clarifies everything. Thank you..! :-)

Re: How do you use BinaryHeap with Array (or just make a growable heap)?

2011-03-28 Thread Jonathan M Davis
On 2011-03-28 05:35, Magnus Lie Hetland wrote: > I need a (growable) binary heap, and I'm trying to avoid writing one > myself (which isn't too hard, of course :) ... but for some reason I > can't figure out how to use Phobos to do it. > > I've seen stated (e.g., by Andrei and in the docs) that th

Re: Container access in std.container

2011-03-28 Thread Ishan Thilina
I am using DGC due to the problems I'm witnessing with DMD. I tried a similar approach. But the following error comes. " structures.d:4: Error: module container cannot read file 'std/container.d' import path[0] = /usr/lib/gcc/x86_64-linux-gnu/4.3.5/../../../../include/d/4.3.5/x86_64-linux-gnu imp

Re: null Vs [] return arrays

2011-03-28 Thread bearophile
Steven Schveighoffer: > So essentially, you are getting the same thing, but using [] is slower. It seems I was right then, thank you and Kagamin for the answers. Bye, bearophile

Re: Little quiz

2011-03-28 Thread bearophile
Kai Meyer: > auto f2 = foo().tupleof; Thank you. From the output of this line of code the problem seems not caused by the static foreach. Bye, bearophile

Re: std.conv.to can't convert to bool?

2011-03-28 Thread Andrej Mitrovic
It can't implicitly convert an int to a bool. The C function returns an int.

Re: object.d: Error: module object is in file 'object.d' which cannot be read

2011-03-28 Thread spir
On 03/28/2011 04:49 PM, Ishan Thilina wrote: now I get a whole lot more errors :s. " ishan@ishan-Ubu-I1464:~/Geany Projects$ dmd untitle.d /usr/include/d/dmd/phobos/object.d(51): C-style function pointer and pointer to array syntax is deprecated. Use 'function' to declare function pointers /usr

Re: std.conv.to can't convert to bool?

2011-03-28 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Wow not a minute later and I get bitten by my own solution. A C > function returned 1 for a supported feature, and -1 otherwise. And of > course -1 got converted to true, so then I had a bug in my code. > > Damn silly C functions which return -1 when they should return 0.

Re: unit testing

2011-03-28 Thread David Nadlinger
On 3/28/11 5:55 PM, Caligo wrote: and how does one do unit testing with GDC? It works fine with DMD, but GDC doesn't do unit testing when -unittest is supplied. -funittest, IIRC. David

Re: Container access in std.container

2011-03-28 Thread Jonathan M Davis
On 2011-03-28 07:48, David Nadlinger wrote: > --- > import std.container; > import std.stdio; > > void main() { > auto rb = redBlackTree(4, 1, 2, 3); > foreach (e; rb) { > writeln(e); > } > } > --- I believe that the redBlackTree function is only in the git repository at

Re: unit testing

2011-03-28 Thread Caligo
On Mon, Mar 28, 2011 at 9:34 AM, David Nadlinger wrote: > On 3/28/11 4:23 PM, Ishan Thilina wrote: >> >> I see that almost all of the phobos library files have "unittests". Were >> these >> unit tests were created using some framework? If so, then what is it? >> >> Thank you...! > > No, these unit

Re: Where does the template parameter E come from?

2011-03-28 Thread simendsjo
On 28.03.2011 17:07, David Nadlinger wrote: On 3/28/11 4:54 PM, simendsjo wrote: When running compose with two arguments, the implementation uses the template parameter E. I don't understand what's going on here as E isn't submitted to the template - what type is E? […] typeof({ E a; return fun0

Re: Where does the template parameter E come from?

2011-03-28 Thread David Nadlinger
On 3/28/11 5:14 PM, simendsjo wrote: On 28.03.2011 17:07, David Nadlinger wrote: On 3/28/11 4:54 PM, simendsjo wrote: When running compose with two arguments, the implementation uses the template parameter E. I don't understand what's going on here as E isn't submitted to the template - what ty

Re: Where does the template parameter E come from?

2011-03-28 Thread David Nadlinger
On 3/28/11 4:54 PM, simendsjo wrote: When running compose with two arguments, the implementation uses the template parameter E. I don't understand what's going on here as E isn't submitted to the template - what type is E? […] typeof({ E a; return fun0(fun1(a)); }()) doIt(E)(E a) { […] } doIt

Re: Where does the template parameter E come from?

2011-03-28 Thread simendsjo
On 28.03.2011 16:54, simendsjo wrote: When running compose with two arguments, the implementation uses the template parameter E. I don't understand what's going on here as E isn't submitted to the template - what type is E? I've also seen this in unary/binaryFun using ElementType. template comp

Re: Little quiz

2011-03-28 Thread Kai Meyer
On 03/24/2011 06:50 PM, 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

Re: clear()

2011-03-28 Thread Kai Meyer
On 03/25/2011 01:10 PM, Dr.Smith wrote: To empty many arrays of various types, rather than: clear(arr1); clear(arr2); ... clear(arrN); is there something like: clear(ALL); No, but perhaps you can do a: foreach(a; ALL) a.clear() But that would require you having an iterable sequence that c

Where does the template parameter E come from?

2011-03-28 Thread simendsjo
When running compose with two arguments, the implementation uses the template parameter E. I don't understand what's going on here as E isn't submitted to the template - what type is E? I've also seen this in unary/binaryFun using ElementType. template compose(fun...) { alias composeImpl!(fun)

Re: object.d: Error: module object is in file 'object.d' which cannot be read

2011-03-28 Thread Ishan Thilina
@Jonathan: Yeah I checked. It's there :s. I dont know what has gone wrong, but I'm using the default settings . I have GDC installed too. Can this have any connection with this problem( just a wild guess ) ? @Jacob: I wasn't sure about which libraries you were talking about. The only lib set I

Re: Container access in std.container

2011-03-28 Thread David Nadlinger
On 3/28/11 4:17 PM, Ishan Thilina wrote: I know that D has some Containers implemented by default( such as a a List, Red-black tree, Array). In C++ these data structures can be used as follows. #include int main(){ std::vector myVector; std::vector::iterator myIterator; } Th

Re: unit testing

2011-03-28 Thread David Nadlinger
On 3/28/11 4:23 PM, Ishan Thilina wrote: I see that almost all of the phobos library files have "unittests". Were these unit tests were created using some framework? If so, then what is it? Thank you...! No, these unit test were just written by hand while writing the corresponding pieces of c

unit testing

2011-03-28 Thread Ishan Thilina
I see that almost all of the phobos library files have "unittests". Were these unit tests were created using some framework? If so, then what is it? Thank you...!

Re: Sample source code for D

2011-03-28 Thread Ishan Thilina
@Denis: The tutorials in the dsource were very helpful. I have read most of those articles that are in the prowiki( the ones you have given links to). As you have stated they are more suited for beginners :-/ . Thank you for the help :)

Container access in std.container

2011-03-28 Thread Ishan Thilina
I know that D has some Containers implemented by default( such as a a List, Red-black tree, Array). In C++ these data structures can be used as follows. #include int main(){ std::vector myVector; std::vector::iterator myIterator; } Then I can use "myIterator" to manipulate "my

Re: null Vs [] return arrays

2011-03-28 Thread Steven Schveighoffer
On Sun, 27 Mar 2011 09:37:47 -0400, bearophile wrote: I have compiled this little D2 program: int[] foo() { return []; } int[] bar() { return null; } void main() {} Using DMD 2.052, dmd -O -release -inline test2.d This is the asm of the two functions: _D5test23fooFZAicomda

Re: inline functions

2011-03-28 Thread Steven Schveighoffer
On Fri, 25 Mar 2011 22:04:20 -0400, 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 d

How do you use BinaryHeap with Array (or just make a growable heap)?

2011-03-28 Thread Magnus Lie Hetland
I need a (growable) binary heap, and I'm trying to avoid writing one myself (which isn't too hard, of course :) ... but for some reason I can't figure out how to use Phobos to do it. I've seen stated (e.g., by Andrei and in the docs) that the standard way is combining BinaryHeap with an Array.

Re: Sample source code for D

2011-03-28 Thread spir
On 03/28/2011 05:43 AM, Ishan Thilina wrote: @ David: I'm looking for example code that explains specific pieces of functionality :) @Lutger: Those two links were really helpful :). Thank you :) There are tutorial examples of D code at DSource; they were initially D1, but many of them are c

Re: null Vs [] return arrays

2011-03-28 Thread Kagamin
bearophile Wrote: > Kagamin: > > > [] is not null, it's an array of 0 elements, what is done exactly. > > edx points to the allocated array. > > I don't understand what you say. I think the caller of foo() and bar() > receive the same thing, two empty registers. I think that cast(int[])null and

Re: object.d: Error: module object is in file 'object.d' which cannot be read

2011-03-28 Thread Jacob Carlborg
On 2011-03-27 23:05, Jonathan M Davis wrote: On 2011-03-27 13:20, Jacob Carlborg wrote: On 2011-03-27 21:24, Ishan Thilina wrote: @Jacob: An error comes when the " ./dvm install dvm" command is given. " ./dvm: error while loading shared libraries: libz.so.1: cannot open shared object file: No