Jonathan M Davis <> changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |
           Severity|normal                      |enhancement

--- Comment #4 from Jonathan M Davis <> 2011-03-10 08:54:10 
PST ---
Ah, okay. I relooked at the code, at that version of replace _should_ be
returning a new string instead of making the changes in place (it's the one
which takes indices which makes the changes in place). The problem is still
that you're giving it an immutable string. replace takes a range for its last 2
arguments. Normally, immutable ranges are useless. You can't pop their front
(because they're immutable), and sometimes you can't even get their front,
because their front property isn't const or immutable. So, in the general case,
passing an immutable range to a function just doesn't work. The current
template constraints for std.array.replace reflect that.

However, arrays are a bit funny in that the compiler understands that you can
get away with copying an array without altering its immutable original, so it's
legal to take an immutable array (or string) and pass it to a function which
takes an array with immutable elements but a mutable array (so it could have a
paramater of string and yet take an immutable string). So, the template
constraint _could_ be adjusted to allow for immutable arrays, even though it
couldn't take immutable ranges which _aren't_ arrays.

So, I'll reopen this an enhancement. However, I would point out that you
probably don't want to be in the habit of using immutable ranges. While it does
sometimes work with arrays, since the compiler understands them and lets them
get away with some stuff that normal types can't, in the general case,
immutable ranges are pretty much useless.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to