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

Justin Johansson no at spam.com
Tue Jul 20 06:36:57 PDT 2010


Perhaps this is a philosophical question, like what is time, though it
is also a novice programmer question as well.  The question exactly
being:

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

May I please petition respondents not to answer in terms of PL syntax.
That is, this question is not about optional parentheses which some
PL's use to make values and nullary function calls look syntactical
alike.

Going beyond syntax and into semantics, does the D language have
any special "opinion" or idiom relating to constant/immutable
values versus nullary function calls?

 From my observation, the Scala PL community has had similar questions
poised in the past (about the difference between val's and nullary
functions) and their answer has largely given into constraints
imposed upon Scala's implementation and semantics as are
implementable on the Java Virtual Machine (JWM).

Thanks for answers,
Justin Johansson







More information about the Digitalmars-d mailing list