Postblit bug

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 21 11:26:26 PDT 2014


21-Oct-2014 05:38, Jonathan M Davis via Digitalmars-d пишет:
> On Sunday, October 19, 2014 22:33:32 Dmitry Olshansky via Digitalmars-d wrote:
>> 17-Oct-2014 16:42, Marco Leise пишет:
>>> Am Fri, 17 Oct 2014 00:42:24 +0000
>>> schrieb "IgorStepanov" <wazar at mail.ru>:
>>>
>>> OK, I've run into the same problem and there is no line
>>> number, just:
>>>
>>> Error: immutable method Lib.Sys.File.File.~this is not callable using a
>>> mutable object Error: mutable method Lib.Sys.File.File.~this is not
>>> callable using a immutable object
>>>
>>> haha! I should start from scratch.
>>
>> Been there. Which implies that we can't have ref-counted const object
>> (or ref-count has to leave outside of immutable section).
>
> Yeah. Ref-counting and const do not mix in D. The ref-counting would violate
> const unless it's in a wrapper object or in a table somewhere. The wrapper
> fails as soon as it ends up being const (either directly or because it's
> inside of another object that's been marked const). And having a table
> somewhere outside the object or any wrapper makes it so that it doesn't work
> with pure. There are some serious, practical downsides to transitive, physical
> const like D has.

They pretty much boil down to DO NOT use const everywhere, honestly.

> And I don't think that any of us really know yet where the
> line is between where const should and shouldn't be used. Too often, the
> solution is to use it everywhere or to use it nowhere. And some folks violate
> it and try and make it more like logical const (e.g. as I understand it,
> vibe.d does ref-counting with const objects by casting away const and then
> mutating the ref-count, which is definitely a risky thing to be doing and
> arguably should never be done - but with the strong restrictions of D's const,
> it's exactly the sort of thing that people are going to be tempted to do).
>

Awful.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list