logical const idea - scratchspace
Tove
tove at fransson.se
Mon May 14 16:27:16 PDT 2012
On Monday, 14 May 2012 at 21:19:43 UTC, Steven Schveighoffer
wrote:
> On Mon, 14 May 2012 17:11:14 -0400, Alex Rønne Petersen
> <xtzgzorex at gmail.com> wrote:
>
>> Another concern I have is that this couples a feature tightly
>> to the implementation of the GC. What if another GC doesn't
>> use the same allocation scheme?
>
> newScratchSpace uses GC.malloc to ensure the block is big
> enough. The GC
> must support returning a block of memory large enough to hold
> the
> requested bytes.
>
> It's not tightly coupled, even though it depends on the GC.
>
> -Steve
It is an interesting idea..., but... we cannot assume that none
of the current/future D compilers can make false 'alias
assumptions' since it only sees const pointers? something similar
to 'mutable' is needed...
A way to work around it would be to use 'volatile this' access,
that would kinda force the compiler to do the right thing when
overriding const... but sadly it's deprecated, and as far as I
know there is no alternative...
btw how is that intended to work when using a pointer to a
hardware register?
More information about the Digitalmars-d
mailing list