TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: BALOG PAL
from: THOMAS MAEDER
date: 1997-07-26 13:28:00
subject: mutable

BP> I once ran into that problem: I had a list class that could be acces
BP> an array, with simple integral index and [] operator. It had a priva
BP> that stored the last accessed index and its pointer, so traversing t
BP> in sequential, upward direction was fast as a real array. But that r
BP> operator could not be made const, as one could expect, and you could
BP> a constant (by value) list here and there because of that internal m
I don't think that this  is  very  good  design.  I'd  rather  use  an
iterator to store the current state of an iteration.
BP> So that mutable proposal can really help. The only problem is that i
Yes.  It's  useful in cases where the values of an object's attributes
are modified but not the object's state as perceived by its clients.
An  example is objects performing lazy evaluation. Toward its clients,
an object changes its state when the state of another object  changes
of  which its state depends. The object's implementation may defer the
state update to the moment when the state is retrieved by a client.
BP> yet supported in compilers.  Or did anyone see it implemented?
Borland C++ supports it.
Thomas
---
 þ MM 1.0 #0113 þ Einsamkeit geniesst man am besten zu zweit
---------------
* Origin: McMeier & Son BBS (2:301/138)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.