Opaque structs

monarch_dodra monarchdodra at gmail.com
Fri Jun 28 01:11:25 PDT 2013


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 
>> pointer")
>>    this();
>>
>>    @disable("S is an opaque C type and must only be used as a 
>> pointer")
>>    this(this);
>> }
>>
>> void main()
>> {
>>    S* s1;  // ok
>>    S s2;  // user error
>> }
>> -----
>>
>> [1] : http://d.puremagic.com/issues/show_bug.cgi?id=8728
>
> +1.  Anything that makes error messages clearer is a win in my 
> book and there is precedents for it in @deprecate(msg) which 
> was a clear win.

+1 also. I was going to say "deprecated does it that way, so 
should disable", but that's already in the ticket ^^


More information about the Digitalmars-d-learn mailing list