Re: Opaque structs

2013-06-30 Thread monarch_dodra
On Sunday, 30 June 2013 at 08:18:39 UTC, Johannes Pfau wrote: Am Sat, 29 Jun 2013 17:38:38 +0200 schrieb "monarch_dodra" : On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote: > Shouldn't doing anything value-related on > an empty struct be invalid anyway? Why ? The fact that the s

Re: Opaque structs

2013-06-30 Thread Johannes Pfau
Am Sat, 29 Jun 2013 17:38:38 +0200 schrieb "monarch_dodra" : > On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote: > > Shouldn't doing anything value-related on > > an empty struct be invalid anyway? > > Why ? > > The fact that the struct has no members is an implementation > detail

Re: Opaque structs

2013-06-29 Thread monarch_dodra
On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote: Shouldn't doing anything value-related on an empty struct be invalid anyway? Why ? The fact that the struct has no members is an implementation detail which should have no impact on the user of the struct.

Re: Opaque structs

2013-06-29 Thread monarch_dodra
On Saturday, 29 June 2013 at 12:58:51 UTC, Johannes Pfau wrote: Am Sat, 29 Jun 2013 10:54:32 +0200 schrieb "Maxim Fomin" : On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote: > Am Fri, 28 Jun 2013 22:16:33 +0200 > schrieb Andrej Mitrovic : > >> On 6/28/13, Johannes Pfau wrote: >> >

Re: Opaque structs

2013-06-29 Thread Andrej Mitrovic
On 6/29/13, Johannes Pfau wrote: > Shouldn't doing anything value-related on > an empty struct be invalid anyway? Maybe, maybe not. I could imagine it would cause problems if we simply disallowed it, e.g. if you want to copy attributes from one declaration to another.

Re: Opaque structs

2013-06-29 Thread Johannes Pfau
Am Sat, 29 Jun 2013 10:54:32 +0200 schrieb "Maxim Fomin" : > On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote: > > Am Fri, 28 Jun 2013 22:16:33 +0200 > > schrieb Andrej Mitrovic : > > > >> On 6/28/13, Johannes Pfau wrote: > >> > A naive question: Why isn't struct S {} enough? This s

Re: Opaque structs

2013-06-29 Thread Maxim Fomin
On Saturday, 29 June 2013 at 08:01:17 UTC, Johannes Pfau wrote: Am Fri, 28 Jun 2013 22:16:33 +0200 schrieb Andrej Mitrovic : On 6/28/13, Johannes Pfau wrote: > A naive question: Why isn't struct S {} enough? This should > be a > struct with size 0 so why do we need to disable the > construct

Re: Opaque structs

2013-06-29 Thread Johannes Pfau
Am Fri, 28 Jun 2013 22:16:33 +0200 schrieb Andrej Mitrovic : > On 6/28/13, Johannes Pfau wrote: > > A naive question: Why isn't struct S {} enough? This should be a > > struct with size 0 so why do we need to disable the constructor and > > postblit explicitly? > > Because the user should never

Re: Opaque structs

2013-06-28 Thread Andrej Mitrovic
On 6/28/13, Johannes Pfau wrote: > A naive question: Why isn't struct S {} enough? This should be a struct > with size 0 so why do we need to disable the constructor and postblit > explicitly? Because the user should never be able to use such a struct by value, in other words a user might mistake

Re: Opaque structs

2013-06-28 Thread Johannes Pfau
Am Fri, 28 Jun 2013 03:40:31 +0200 schrieb Andrej Mitrovic : > struct S > { > @disable("S is an opaque C type and must only be used as a > pointer") this(); > > @disable("S is an opaque C type and must only be used as a > pointer") this(this); > } A naive question: Why isn't struct S {}

Re: Opaque structs

2013-06-28 Thread Andrej Mitrovic
On 6/28/13, Andrej Mitrovic wrote: > Unfortunately this tends to spawn unreadable error messages: It looks like there's also a blocking bug: http://d.puremagic.com/issues/show_bug.cgi?id=10497 So I'll have to use my new technique instead anyway. :p

Re: Opaque structs

2013-06-28 Thread monarch_dodra
On Friday, 28 June 2013 at 02:17:06 UTC, Brad Anderson wrote: On Friday, 28 June 2013 at 01:40:44 UTC, Andrej Mitrovic wrote: Note that if we implement Issue 8728[1], we could even create a better error message via: - struct S { @disable("S is an opaque C type and must only be used as a

Re: Opaque structs

2013-06-27 Thread Brad Anderson
On Friday, 28 June 2013 at 01:40:44 UTC, Andrej Mitrovic wrote: Note that if we implement Issue 8728[1], we could even create a better error message via: - struct S { @disable("S is an opaque C type and must only be used as a pointer") this(); @disable("S is an opaque C type