Re: Why an abstract pointer cannot be used as value in an associate array?

2011-09-30 Thread Christophe
Cheng Wei , dans le message (digitalmars.D.learn:29865), a écrit : > Thanks a lot. This solves the problem. > > However, it breaks the abstractness. Now in D side, we can call > auto v = ab(). This does not make sense, because then &v cannot be used > in the C library. > > I don't understand why

Re: Why an abstract pointer cannot be used as value in an associate array?

2011-09-29 Thread Cheng Wei
Thanks a lot. This solves the problem. However, it breaks the abstractness. Now in D side, we can call auto v = ab(). This does not make sense, because then &v cannot be used in the C library. I don't understand why when we manipulate AB*, D compiler needs to know the size of struct ab. Moreover,

Re: Why an abstract pointer cannot be used as value in an associate array?

2011-09-29 Thread Cheng Wei
The problem is that the void* cannot convert back to AB* when we want to use it in c library. Just don't understand why the cast(AB*)p (p is void *) needs to know the size of AB. Is there any unsafe cast which can blindly cast the pointers?

Re: Why an abstract pointer cannot be used as value in an associate array?

2011-09-29 Thread Timon Gehr
On 09/29/2011 01:28 PM, Trass3r wrote: Am 29.09.2011, 06:51 Uhr, schrieb Cheng Wei : extern(C) { struct ab; } ab*[int] map; void main() { map.clear(); } Cannot be compiled. Why? Thanks. Just use void* for opaque pointers in D. Or an empty struct. struct ab{}

Re: Why an abstract pointer cannot be used as value in an associate array?

2011-09-29 Thread Trass3r
Am 29.09.2011, 06:51 Uhr, schrieb Cheng Wei : extern(C) { struct ab; } ab*[int] map; void main() { map.clear(); } Cannot be compiled. Why? Thanks. Just use void* for opaque pointers in D.

Re: Why an abstract pointer cannot be used as value in an associate array?

2011-09-29 Thread Christophe
what is the error message ?

Re: Why an abstract pointer cannot be used as value in an associate array?

2011-09-28 Thread bearophile
Cheng Wei: > extern(C) { > struct ab; > } > > ab*[int] map; > > void main() { > map.clear(); > } > > > Cannot be compiled. Why? It's not specific of associative arrays: extern(C) { struct AB; } AB*[] arr; void main() { arr.length += 1; } Bye, bearophile

Why an abstract pointer cannot be used as value in an associate array?

2011-09-28 Thread Cheng Wei
extern(C) { struct ab; } ab*[int] map; void main() { map.clear(); } Cannot be compiled. Why? Thanks.