The Status of Const

Nick Sabalausky a at a.a
Thu Aug 12 19:57:47 PDT 2010


"Justin Johansson" <no at spam.com> wrote in message 
news:i42ba3$1br$1 at digitalmars.com...
> Nick Sabalausky wrote:
>> "Justin Johansson" <no at spam.com> wrote in message 
>> news:i424ac$27nb$1 at digitalmars.com...
>>> Graham St Jack wrote:
>>>> Is there any plan to introduce some way of having a mutable reference 
>>>> to an immutable class object on the heap? Do others see this as a 
>>>> problem at all?
>>> For embedded microsystems (i.e. with ROM/RAM) this is a problem.  It
>>> is a common use case to have a mutable reference (in RAM) to some
>>> objects that reside in ROM.  Obviously anything in ROM is guaranteed
>>> by hardware to be immutable.  So, yes, this is a problem in a
>>> wider sense.
>>
>> Would there every really be anything in ROM though that would be 
>> appropriate as a class though, as opposed to, say, a struct? I've never 
>> heard of an object with a vtable being stored in ROM.
>
> Yes, well back in my embedded C++ days yes did so.  But just because I
> did doesn't necessarily make it a common use case.  Strike 'common'
> above and replace with 'valid.
>

Interesting.

> Anyway, what about a mutable reference to an immutable struct (in ROM)?

Since structs are value types in D, wouldn't a reference to it (mutable or 
otherwise) *have* to be a pointer?





More information about the Digitalmars-d mailing list