Casting away immutability

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 4 12:46:32 PDT 2015


On Friday, 4 September 2015 at 13:29:42 UTC, Kagamin wrote:
> On Friday, 4 September 2015 at 09:05:07 UTC, Marc Schütz wrote:
>> Note that you can however achieve immutability by using a 
>> _private_ read-only mapping.
>
> man pages say the behavior is unspecified.

The Linux man page says:

"It is unspecified whether changes made to the file after the 
mmap() call are visible in the mapped region."

I.e., you're right. I interpreted this to refer only to portions 
of the file that have never been accessed, but reading it again, 
it doesn't say that... And it makes sense, as this makes it 
possible to drop clean pages on memory pressure, instead of 
swapping them out.


More information about the Digitalmars-d-learn mailing list