Re: attribute bug?

2012-11-10 Thread goofwin
On Saturday, 10 November 2012 at 18:35:57 UTC, Jonathan M Davis wrote: Object-oriented code not use virtual functions much? If you don't need virtual functions, then use a struct, not a class. Classes are polymorphic. Structs are not. In general, it doesn't make a lot of sense to use a class

Re: no size for type nothrow extern (Windows) int()

2012-11-10 Thread cal
On Sunday, 11 November 2012 at 02:55:09 UTC, Alex Rønne Petersen wrote: Can you give a self-contained repro that illustrates the problem? Also, please use core.sys.windows.windows instead. The std.c.* package is going to be deprecated soon-ish. import core.sys.windows.windows; void main() {

Re: no size for type nothrow extern (Windows) int()

2012-11-10 Thread cal
On Sunday, 11 November 2012 at 02:55:09 UTC, Alex Rønne Petersen wrote: Can you give a self-contained repro that illustrates the problem? Also, please use core.sys.windows.windows instead. The std.c.* package is going to be deprecated soon-ish. import core.sys.windows.windows; void main() {

Re: no size for type nothrow extern (Windows) int()

2012-11-10 Thread Alex Rønne Petersen
On 11-11-2012 02:49, cal wrote: I want to call Windows api function VirtualAlloc. I include std.c.windows.windows but get the following error from dmd 2.061 (and 2.060): Error: no size for type nothrow extern (Windows) int() What does this message mean? If I provide my own prototype of the func

no size for type nothrow extern (Windows) int()

2012-11-10 Thread cal
I want to call Windows api function VirtualAlloc. I include std.c.windows.windows but get the following error from dmd 2.061 (and 2.060): Error: no size for type nothrow extern (Windows) int() What does this message mean? If I provide my own prototype of the function, same error.

Re: Performance of hashes and associative arrays

2012-11-10 Thread Ali Çehreli
On 11/10/2012 05:37 AM, Joseph Rushton Wakeling wrote: > On 11/07/2012 07:38 AM, "Raphaël.Jakse" > "@puremagic.com wrote: >> We want to be able to get the hash of s. Therefore, we re-implement >> the toHash >> method of the Student class : > > OK, now I'm curious. Assuming I don't write a custom r

Re: Serialization library with support for circular references?

2012-11-10 Thread Andrej Mitrovic
On 11/10/12, nixda wrote: > You can try vibe.d bson serialization. > http://vibed.org/api/vibe.data.bson/serializeToBson It doesn't handle them either. Anyway I've implemented it for msgpack (took a whole of 30 minutes, it's a great and readable codebase), I just have to write some more extensive

Re: Serialization library with support for circular references?

2012-11-10 Thread nixda
You can try vibe.d bson serialization. http://vibed.org/api/vibe.data.bson/serializeToBson On Saturday, 10 November 2012 at 21:23:03 UTC, Andrej Mitrovic wrote: 11/10/12, Andrej Mitrovic wrote: I've been using msgpack for a while, unfortunately I've just discovered it doesn't support serial

Re: Serialization library with support for circular references?

2012-11-10 Thread Andrej Mitrovic
11/10/12, Andrej Mitrovic wrote: > I've been using msgpack for a while, unfortunately I've just > discovered it doesn't support serializing circular references > (http://jira.msgpack.org/browse/MSGPACK-81) Anyway I think I'll be able to hack-in circular reference support to msgpack, but it's not

Re: Serialization library with support for circular references?

2012-11-10 Thread Andrej Mitrovic
On 11/10/12, Jacob Carlborg wrote: > Although Orange is probably not very fast and it currently only has an > XML archive. Heh yeah I'm actually reading XML into classes and then want to serialize this for faster access when re-running the app, so it probably wouldn't be a good idea to serialize

Re: Serialization library with support for circular references?

2012-11-10 Thread Jacob Carlborg
On 2012-11-10 13:42, Andrej Mitrovic wrote: Orange doesn't work with circular references either. Is there any other serialization library that supports this scenario? I'm looking for something fast, and binary format is ok, I don't need a user-readable format. If Orange doesn't work with circu

Serialization library with support for circular references?

2012-11-10 Thread Andrej Mitrovic
I've been using msgpack for a while, unfortunately I've just discovered it doesn't support serializing circular references (http://jira.msgpack.org/browse/MSGPACK-81), e.g.: import msgpack; class Foo { int x; Bar obj; } class Bar { int x; Foo obj; } void main() { auto foo =

Re: Performance of hashes and associative arrays

2012-11-10 Thread Dan
On Saturday, 10 November 2012 at 18:18:07 UTC, Joseph Rushton Wakeling wrote: On 11/07/2012 07:38 AM, "Raphaël.Jakse" "@puremagic.com wrote: We want to be able to get the hash of s. Therefore, we re-implement the toHash method of the Student class : OK, now I'm curious. Assuming I don't writ

Re: attribute bug?

2012-11-10 Thread Jonathan M Davis
On Saturday, November 10, 2012 11:03:31 Jacob Carlborg wrote: > On 2012-11-10 06:28, Jonathan M Davis wrote: > > package restricts access to the same package. D has no concept like C#'s > > internal, because it doesn't have assemblies. > > I'm not entirely sure how assemblies work in C# but couldn

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Artur Skawina
On 11/09/12 23:45, Timon Gehr wrote: > On 11/09/2012 10:24 PM, Philippe Sigaud wrote: >> >> Timon: >> >> The D front end I am developing can already handle it. >> >> >> Developed in D, I suppose? >> > > Yes. Public? License? URL? artur

Re: attribute bug?

2012-11-10 Thread Jonathan M Davis
On Saturday, November 10, 2012 08:28:00 goofwin wrote: > I think that it is unsuccessful decision by the language > designers, because object oriented code use virtual functions not > much in most cases, thence it is useless and bad for performance > or it causes developer to set public and protect

Re: Performance of hashes and associative arrays

2012-11-10 Thread Joseph Rushton Wakeling
On 11/07/2012 07:38 AM, "Raphaël.Jakse" "@puremagic.com wrote: We want to be able to get the hash of s. Therefore, we re-implement the toHash method of the Student class : OK, now I'm curious. Assuming I don't write a custom re-implementation, how would a custom struct or class be hashed? (W

Re: A refinement for pure implementation

2012-11-10 Thread bearophile
Timon Gehr: The point was that the code you gave should work even without your proposed enhancement. So my original question was: do you remember if Hara has already written a patch to fix that bug? :-) Bye, bearophile

Re: Is there a way to initialize a non-assigned structure declaration (or is it a definition)?

2012-11-10 Thread Too Embarrassed To Say
I appreciate all the helpful replies, but I've simplified things to what I belive is the core issue. In C++ (at the risk of becoming a heretic) the language allows me to do the following: struct SnonParameterized { public: int t; float u; SnonParameterized(int tparam, float uparam); };

Re: Casting an array form an associative array

2012-11-10 Thread Jacob Carlborg
On 2012-11-10 17:48, Timon Gehr wrote: The length of an array is the number of elements. sizeof(void)==1 and sizeof(int)==4. The first example reinterprets the ptr and length pair of the void[] as a ptr and length pair of an int[]. The second example adjusts the length so that the resulting arra

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Timon Gehr wrote: > But as this is an undecidable property in general I do not see, that the compiler has to solve the general case--- at least when compiling monolithic code and the executable is only allowed to use types which are initialized at compile time. Upon using several modules the mo

Re: A refinement for pure implementation

2012-11-10 Thread Timon Gehr
On 11/10/2012 05:21 PM, bearophile wrote: Timon Gehr: It is strongly pure regardless of potential aliasing in the return value. This is a bug. This can't be strongly pure: int[] foo2(int[] a) pure { a[0]++; return a; } Bye, bearophile The point was that the code you gave shoul

Re: Casting an array form an associative array

2012-11-10 Thread Timon Gehr
On 11/10/2012 01:20 PM, Jacob Carlborg wrote: The following example: void main() { void[][size_t] aa; aa[1] = [1, 2, 3]; if (auto a = 1 in aa) { writeln(*(cast(int[]*) a)); writeln(cast(int[]) *a); } } Will print: [1, 2, 3, 201359280, 0, 0, 0, 0, 0,

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Timon Gehr
On 11/10/2012 10:12 AM, Manfred Nowak wrote: Timon Gehr wrote: In theory yes, but [...] What a pity. Because in the code given only the types Elem!0 and Elem!1 must be indeed initialized. ... In this specific case, yes. But as this is an undecidable property in general, detecting and explo

Re: A refinement for pure implementation

2012-11-10 Thread bearophile
Timon Gehr: It is strongly pure regardless of potential aliasing in the return value. This is a bug. This can't be strongly pure: int[] foo2(int[] a) pure { a[0]++; return a; } Bye, bearophile

A refinement for pure implementation

2012-11-10 Thread bearophile
Do you remember if Hara has implemented a patch to allow a2 to be immutable? int[] foo1(int x) pure { return null; } int[] foo2(string s) pure { return null; } void main() { immutable a1 = foo1(10); // OK immutable a2 = foo2("hello"); // currently error } The idea behind this

Re: Is there a way to initialize a non-assigned structure declaration (or is it a definition)?

2012-11-10 Thread Nick Sabalausky
On Sat, 10 Nov 2012 00:35:05 +0100 "Too Embarrassed To Say" wrote: > > auto p3 = Parameterized!(int, double, bool, char)(57, 7.303, > false, 'Z'); // compiles > // but not > // Parameterized!(int, double, bool, char)(93, 5.694, true, 'K') > p4; That's as expected. Variable declarations are of

Re: A refinement for pure implementation

2012-11-10 Thread Timon Gehr
On 11/10/2012 03:32 PM, bearophile wrote: Do you remember if Hara has implemented a patch to allow a2 to be immutable? int[] foo1(int x) pure { return null; } int[] foo2(string s) pure { return null; } void main() { immutable a1 = foo1(10); // OK immutable a2 = foo2("hello")

Re: Performance of hashes and associative arrays

2012-11-10 Thread Dan
On Saturday, 10 November 2012 at 07:55:18 UTC, Raphaël Jakse wrote: Hello, Thanks for this complete answer. I will take a look to your code. Ok - good. I've been using 2.061 which I just realized allows "dup" on an associative array, a feature which was not available in 2.060. So mixin(Dup)

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Nick Sabalausky
On Sat, 10 Nov 2012 10:33:39 + (UTC) Manfred Nowak wrote: > Nick Sabalausky wrote: > > > I really don't see the relevance > > Please look at the definition of R: > struct R > { > int value; > d_list!R Rlist; > } > > If no recursion was wanted the OP should have written: > d_lis

Casting an array form an associative array

2012-11-10 Thread Jacob Carlborg
The following example: void main() { void[][size_t] aa; aa[1] = [1, 2, 3]; if (auto a = 1 in aa) { writeln(*(cast(int[]*) a)); writeln(cast(int[]) *a); } } Will print: [1, 2, 3, 201359280, 0, 0, 0, 0, 0, 0, 0, 0] [1, 2, 3] The first value seems to contain s

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Nick Sabalausky wrote: > But the OP was never trying to do anything like that. See digitalmars.D.learn:40991 -manfred

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Rob T wrote: > and the problem I'm experiencing is definitely a compiler bug I do not see that. Please work on my messages digitalmars.D.learn:40990 and digitalmars.D.learn:40991. -manfred

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Nick Sabalausky wrote: > I really don't see the relevance Please look at the definition of R: struct R { int value; d_list!R Rlist; } If no recursion was wanted the OP should have written: d_list!(R*) Rlist; In digitalmars.D.learn:40990 I already asked for an explanation. -manfred

Re: Recursive data structure using template won't compile

2012-11-10 Thread Manfred Nowak
Rob T wrote: > I want to create a simple recursive data structure as follows: > > struct R > { > int value; > d_list!R Rlist; > } I do not see any usage for the member `d_list!R Rlist'. Please explain. -manfred

Re: attribute bug?

2012-11-10 Thread Jacob Carlborg
On 2012-11-10 06:28, Jonathan M Davis wrote: package restricts access to the same package. D has no concept like C#'s internal, because it doesn't have assemblies. I'm not entirely sure how assemblies work in C# but couldn't one say that everything in D is internal unless explicitly marked as

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-10 Thread Manfred Nowak
Timon Gehr wrote: > In theory yes, but [...] What a pity. Because in the code given only the types Elem!0 and Elem!1 must be indeed initialized. The fact, that the specification of the template describes a family of types with an infinite number of members should not force the front end to ch

Re: Performance of hashes and associative arrays

2012-11-10 Thread Raphaël Jakse
Hello, Thanks for this complete answer. I will take a look to your code. Additionally, Ali gave me a really interesting link about hashing, good practices, what is efficient, etc. If you didn't read it, it might interest you. Here it is: http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_