D's treatment of values versus side-effect free nullary functions

BCS none at anon.com
Wed Jul 21 07:32:06 PDT 2010


Hello Justin,

> "What is the difference between a (constant/immutable) value and the
> result of calling a side-effect free function that returns the same?"

A const value can't be changed from the current context but could be changed 
via another alias or inside a non side effect free function or via one of 
those in another thread.

An immutable value can't change, end of story.

The value a side-effect free function returns can change as soon as anything 
changes, a local var (via nested functions) global var or anything addressable 
through them.

The function most closely resembles the const var.


-- 
... <IXOYE><





More information about the Digitalmars-d mailing list