http://d.puremagic.com/issues/show_bug.cgi?id=2832
--- Comment #4 from Max Samukha <samu...@voliacable.com> 2009-10-13 08:44:23 PDT --- > I think the existing behaviour -- that you cannot change any of the parameters > in a pure function -- is simple and intuitive: pure functions can only modify > variables which they created themselves. But the passed-by-value parts of the arguments are copied and consequently can be qualified as "variables which they created themselves". > A rule that pure nested functions can > use indirectly-referenced data, but cannot use parameters which are passed by > value, just seems complicated. I don't think it is too complicated. It can be trivially done like this: pure int foo(in int d, ...) { // now we should be able to use d in pure nested functions because it is // guaranteed to not change during the function call. } > Especially, in the case where a parameter contains a reference to other data, > it seems folly to be allowed to change part of the parameter, but not all of > it. I am not sure. For example, it seems to be fairly intuitive to be able to rebind a string parameter, though changing the referenced part of it is not allowed. I would agree if D's function parameters behaved like aliases to the arguments, but they are more like the function's local variables, which arguments are assigned to. Now that I am trying to purify some functions (most of which have no nested functions) I need to add the useless temporaries to make them compile :( -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------