problem with reduce on array of Tuples

2010-05-27 Thread Adrian Matoga
The following code fails to compile: double sim(Document doc, string query) { alias Tuple!(double, wij, double, wiq) Weights; Document q = Document.fromString(query); Weights[] wi; foreach (s; StrFilt(query)) wi ~= Weights(doc.termFreq(s) *

Re: Finding and invoking struct destructors in D2

2010-05-27 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Pillsy wrote: Hi, all, I was wondering if there's any way to determine at compile time whether a struct has a (non-trivial) destructor associated with it, and whether there's any way to call that destructor without using the delete operator. It

Re: Finding and invoking struct destructors in D2

2010-05-27 Thread Pillsy
== Quote from div0 (d...@users.sourceforge.net)'s article: [...] Most important is this one, which scuppers any change of doing a shared ptr like struct: http://d.puremagic.com/issues/show_bug.cgi?id=3516 Yeah, that basically kills the idea until the bug is fixed. :( Once it is, I think a

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread Larry Luther
Thank you, I had no idea that scope was doing this. I thought that when the docs said that it was being allocated on the stack that I was getting struct like behavior. Simen kjaeraas simen.kja...@gmail.com wrote in message news:op.vc0qlpjovxi...@biotronic-pc.home... | Larry Luther

Re: Finding and invoking struct destructors in D2

2010-05-27 Thread Don
div0 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Pillsy wrote: Hi, all, I was wondering if there's any way to determine at compile time whether a struct has a (non-trivial) destructor associated with it, and whether there's any way to call that destructor without using the delete

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread Larry Luther
bearophile bearophileh...@lycos.com wrote in message news:ht4g3r$vu...@digitalmars.com... | Larry Luther: | | I did not get an error when building and running with DMD 2.042: | | I am using dmd v2.046, and I have taken the good habit of compiling with -w (warnings on). | It seems this error I

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread bearophile
Larry Luther: I'm nonplussed. Could you expand on why D class instances don't need to copy their contents and instances of D structs do? While migrating C++ code to D I've had to convert structs to classes because of the need for inheritance. Why would the need to copy an instance's contents

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread bearophile
Larry Luther: Ok, I've added -w to compilation commands and I've switched back to pure text. Good :-) What am I missing? I have modified a bit your D code like this, to have something with a main() that runs: import std.c.stdio: puts; class A { int x, y; void copy(const A a) {

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread bearophile
See: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.Darticle_id=110554

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread Larry Luther
bearophile bearophileh...@lycos.com wrote in message news:ht4krg$17l...@digitalmars.com... | On the base of your long experience do you like D so far? There are many things that I like and I strongly agree with the failings of C++ mentioned in the docs. I don't like the asymmetry between

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread bearophile
Larry Luther: There are many things that I like and I strongly agree with the failings of C++ mentioned in the docs. D is designed by people that have a good experience of C++, but while probably D avoids some C++ problems, it surely introduces a number of new issues :-) I don't like the

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread Steven Schveighoffer
On Thu, 27 May 2010 17:04:35 -0400, Larry Luther larry.lut...@dolby.com wrote: bearophile bearophileh...@lycos.com wrote in message news:ht4krg$17l...@digitalmars.com... | On the base of your long experience do you like D so far? There are many things that I like and I strongly agree with

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread bearophile
Steven Schveighoffer: I have hoped that at some point, structs can be auto-composed, without a vtable, but you still have to do this manually. I don't understand what you mean here :-) Bye, bearophile

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread Ali Çehreli
bearophile wrote: Larry Luther: Ok, I've added -w to compilation commands and I've switched back to pure text. Good :-) What am I missing? I have modified a bit your D code like this, to have something with a main() that runs: import std.c.stdio: puts; class A { int x, y;

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread Steven Schveighoffer
On Thu, 27 May 2010 17:47:20 -0400, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: I have hoped that at some point, structs can be auto-composed, without a vtable, but you still have to do this manually. I don't understand what you mean here :-) I mean simple

Re: Newbie: copy, assignment of class instances

2010-05-27 Thread Steven Schveighoffer
On Thu, 27 May 2010 18:41:19 -0400, bearophile bearophileh...@lycos.com wrote: Thank you Steven for your explanations, I have done similar things in C and D, but I didn't understand what you meant. A is always put first, that way, a pointer to a B can always be used as a pointer to an A.