On Wed, 28 Sep 2011 16:03:51 -0400, Jonathan M Davis <jmdavisp...@gmx.com>
wrote:
On Wednesday, September 28, 2011 11:31:31 Christophe wrote:
"Jonathan M Davis" , dans le message (digitalmars.D:145479), a écrit :
> But since lazy initializion will _never_ work with immutable
Never say never. One could build a clean and thread-safe way to lazily
initialize fields. Like someone said, even without mutex, if the
function to compute the variable is pure and based on immutable data,
the worst case would be to run the intializing function twice. And the
langage could include mutexes to do prevent that to happen. The fact
that immutable data could, one day, be put in ROM doesn't mean that it
has to. The close issue is like another-one said the issue of
memoization of pure methods.
The very fact that an immutable variable _could_ be put into ROM negates
the
possibility of the semantics being such that you don't have to fully
initialize an immutable variable up front.
No it doesn't. If it's in ROM, initialize eagerly (which should cost
nothing, done at compile-time). If it's not, initialize lazily.
-Steve