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

2012-11-08 Thread Rob T
There is clearly no recursion in the struct, it terminates at the pointers, therefore it is of finite and knowable size during compile time. R looks like this if value is int dlist!R = struct{ struct*, struct* } R = struct{ int, struct{ struct*, struct* } } node!R = struct{ struct{ int, struct

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

2012-11-08 Thread Nick Sabalausky
On Fri, 9 Nov 2012 01:17:09 + (UTC) Manfred Nowak wrote: > Nick Sabalausky wrote: > > > ALL 3 types have an exact, FINITE size. > > There *IS NO RECURSION* here. > > This conclusion is wrong. Otherwise one can conclude that `s' is not > recursing on itself in this code: > > struct S{ S* n

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

2012-11-08 Thread Manfred Nowak
Nick Sabalausky wrote: > ALL 3 types have an exact, FINITE size. > There *IS NO RECURSION* here. This conclusion is wrong. Otherwise one can conclude that `s' is not recursing on itself in this code: struct S{ S* next;} S s; s.next= &s; ... because `s' has a fixed and finite size. One way to

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

2012-11-08 Thread Rob T
Interestingly, this is a workaround that may be workable somehow. I've even been able to expand it so that the R.value type is determined by a temnplate. struct node( P ) { P payload; node* pred; node* succ; } struct R( V ) { V value; alias node!R N; d_list!N Rlist; } struct

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

2012-11-08 Thread Rob T
On Thursday, 8 November 2012 at 23:05:33 UTC, Nick Sabalausky wrote: Most of big glaring problems have been fixed since then, but unfortunately there's still a number of edge cases yet to be ironed out. Clearly. FWIW, you should be able to work around the issue by making some of the pointers

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

2012-11-08 Thread Andrej Mitrovic
On 11/9/12, Nick Sabalausky wrote: > FWIW, you should be able to work around the issue by making some of the > pointers "void*". You'll lose some type safety and have to remember to > cast things correctly, but it should at least make it compile (although > I haven't tried it). Perhaps another po

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

2012-11-08 Thread Nick Sabalausky
On Thu, 08 Nov 2012 23:28:05 +0100 "Rob T" wrote: > > It could be that the template system simply does not operate as > we expect, which IMO would be unfortunate because it will > describe a system somewhat unrelated to actual coding (a problem > C++ templates are infamous for), or that it is

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

2012-11-08 Thread Rob T
On Thursday, 8 November 2012 at 21:47:55 UTC, Nick Sabalausky wrote: It is *not* the case in his code. He has three actual instantiated structs: R -- 1. int value (4 bytes) 2. d_list!R Rlist (size: TBD) d_list!R -- // **JUST POINTERS** 1. (d_list!R).node* head (

Re: Recursive data structure using template won't compile

2012-11-08 Thread Rob T
On Thursday, 8 November 2012 at 21:50:02 UTC, Nick Sabalausky wrote: On Fri, 09 Nov 2012 01:26:44 +0400 Dmitry Olshansky wrote: Just coming up with an idea how it may fail, not arguing for it being correct ;) Right. Point is, it's a compiler bug. For D, as opposed to C/C++, my understandi

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

2012-11-08 Thread Nick Sabalausky
On Thu, 08 Nov 2012 22:46:46 +0100 "Rob T" wrote: > > So is there a way to retain identical struct types for R by > disabling the not-so-useful-in-my-case template recursion? > There is no template recursion in your code (you have *exactly* 3 concrete types even after all template instantiatio

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

2012-11-08 Thread Nick Sabalausky
On Thu, 8 Nov 2012 21:15:17 + (UTC) Manfred Nowak wrote: > Rob T wrote: > > > In fact, I can define the structure just fine provided that I do > > not use a template. > > .. and if one uses a template one can get an infinite recursion, > because templates include recursion. This is the cas

Re: Recursive data structure using template won't compile

2012-11-08 Thread Nick Sabalausky
On Fri, 09 Nov 2012 01:26:44 +0400 Dmitry Olshansky wrote: > > Just coming up with an idea how it may fail, not arguing for it being > correct ;) Right. Point is, it's a compiler bug.

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

2012-11-08 Thread Rob T
On Thursday, 8 November 2012 at 21:15:17 UTC, Manfred Nowak wrote: Rob T wrote: In fact, I can define the structure just fine provided that I do not use a template. .. and if one uses a template one can get an infinite recursion, because templates include recursion. This is the case in your

Re: Recursive data structure using template won't compile

2012-11-08 Thread Dmitry Olshansky
11/9/2012 12:35 AM, Nick Sabalausky пишет: On Thu, 08 Nov 2012 19:19:52 +0400 Dmitry Olshansky wrote: 11/8/2012 10:39 AM, Rob T пишет: I want to create a simple recursive data structure as follows: struct R { int value; d_list!R Rlist; } Not possible - you don't know the size of

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

2012-11-08 Thread Manfred Nowak
Rob T wrote: > In fact, I can define the structure just fine provided that I do not > use a template. .. and if one uses a template one can get an infinite recursion, because templates include recursion. This is the case in your code. The code I gave elimates that infinite recursion. The code

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

2012-11-08 Thread Rob T
On Thursday, 8 November 2012 at 20:39:29 UTC, Manfred Nowak wrote: Manfred Nowak wrote: or `T' itself must take the lead. `T' was given as: | struct R | { | int value; | d_list!R Rlist; | } ... and using the given changes as well as D-parlor `T' becomes: | struct R { | int value;

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

2012-11-08 Thread Manfred Nowak
Manfred Nowak wrote: > or `T' itself must take the lead. `T' was given as: | struct R | { | int value; | d_list!R Rlist; | } ... and using the given changes as well as D-parlor `T' becomes: | struct R { | int value; | Ancor!R list; | } Because `R' can recurse infinitely over `An

Re: Recursive data structure using template won't compile

2012-11-08 Thread Nick Sabalausky
On Thu, 08 Nov 2012 19:19:52 +0400 Dmitry Olshansky wrote: > 11/8/2012 10:39 AM, Rob T пишет: > > I want to create a simple recursive data structure as follows: > > > > struct R > > { > > int value; > > d_list!R Rlist; > > } > > Not possible - you don't know the size of R at this point.

Re: Recursive data structure using template won't compile

2012-11-08 Thread Rob T
Before I forget, it is important to note that the structure consists of two parts, the value with a list of associated sub-values, along with the list. struct R { int value; d_list!R Rlist; } struct d_list( T ) { struct node { T payload; node* pred; node* succ;

Re: Recursive data structure using template won't compile

2012-11-08 Thread Rob T
On Thursday, 8 November 2012 at 18:45:08 UTC, Manfred Nowak wrote: Rob T wrote: I want to be clear that I'm trying to define a recursive data structure [...] so correct me if there's a reasonable way to get this job done A recursive data structure needs a mooring ... and such a mooring is

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

2012-11-08 Thread Manfred Nowak
Rob T wrote: | struct d_list( T ) | { |struct node |{ | T payload; | node* pred; | node* succ; |} |node* head; |node* tail; | } This doesn't loo like a list. It looks like the ancor of a list. Let me rewrite it and use D-parlor. | struct Ancor( T){ |str

Re: Recursive data structure using template won't compile

2012-11-08 Thread Manfred Nowak
Rob T wrote: > I want to be clear that I'm trying to define a recursive data > structure [...] > so correct me if there's a reasonable way to get this job done A recursive data structure needs a mooring ... and such a mooring is missing in the code given. -manfred

Re: Current status of DLLs

2012-11-08 Thread Benjamin Thaut
Am 08.11.2012 08:43, schrieb Jakob Ovrum: On Wednesday, 7 November 2012 at 10:24:25 UTC, Benjamin Thaut wrote: For example: Exporting the Module init symbol is not supported, so every module that only exists in a dll will generate a linker error. Also I had some cases where even the vtable symbo

Re: C++/D platform matrix

2012-11-08 Thread Benjamin Thaut
Afaik druntime does not support: iOS, Windows Metro, Windows RT(ARM). GDC is only a frontend for gcc, so if you do some magic you might be able to get D to work on any platform that gcc can support. But only if you manage to get the d runtime running on that platform. I know that someone mana

Re: Recursive data structure using template won't compile

2012-11-08 Thread Rob T
I want to be clear that I'm trying to define a recursive data structure, not a recursive D struct, which of course is not possible. The nodes in the d_list are allocated as pointers, and the node size syhould be knowable during compile time, so this is IMO a design flaw with how templates are

Re: Recursive data structure using template won't compile

2012-11-08 Thread Rob T
On Thursday, 8 November 2012 at 17:57:11 UTC, Philippe Sigaud wrote: Rob, your original code: // d-linked list with templated payload struct d_list( T ) { struct node { T payload; node* pred; node* succ; } node* head; node* tail; } compiles just fine for

Re: Recursive data structure using template won't compile

2012-11-08 Thread Philippe Sigaud
Rob, your original code: // d-linked list with templated payload struct d_list( T ) { struct node { T payload; node* pred; node* succ; } node* head; node* tail; } compiles just fine for me (Linux 32bits, DMD 2.060). Even with some exercising, the template

Re: Recursive data structure using template won't compile

2012-11-08 Thread Rob T
On Thursday, 8 November 2012 at 15:19:56 UTC, Dmitry Olshansky wrote: Naturally C++ doesn't have nested struct definitions. I don't have a nested struct, the struct definition defines the type only, and the nodes are allocated as pointers from a new operation when the list is composed. The

C++/D platform matrix

2012-11-08 Thread DypthroposTheImposter
Hey I was wondering which platforms D works on, and more specifically which ones it can work together with C++11(so not DMD C++ since that isn't C++11(I think)). To my knowledge... Windows - Yes can build a D DLL and call it from C++ Linux - Yes ^ MacOS - Yes ^ iOS - I don't think iOS allow

Re: Manually freeing up memory

2012-11-08 Thread Joseph Rushton Wakeling
On 11/08/2012 05:50 AM, Marco Leise wrote: Could it be that you still hold a reference to the raw memory in your data structures ? A slice would be a typical candidate: s.name = raw[a .. b]; You probably checked that already... I don't _think_ so, although there is a point where data is passed

Re: Recursive data structure using template won't compile

2012-11-08 Thread Dmitry Olshansky
11/8/2012 10:39 AM, Rob T пишет: I want to create a simple recursive data structure as follows: struct R { int value; d_list!R Rlist; } Not possible - you don't know the size of R at this point. So determine it compiler looks inside of d_list, and then encounters _node_. It naturally

Re: Recursive data structure using template won't compile

2012-11-08 Thread Nick Sabalausky
On Thu, 08 Nov 2012 07:39:27 +0100 "Rob T" wrote: > I want to create a simple recursive data structure as follows: > > struct R > { > int value; > d_list!R Rlist; > } > > // d-linked list with templated payload > struct d_list( T ) > { > struct node > { >T payload; >