https://d.puremagic.com/issues/show_bug.cgi?id=12408
--- Comment #4 from monarchdo...@gmail.com 2014-03-20 02:02:14 PDT --- (In reply to comment #3) > I thought that the whole point of using inout was to avoid having to > copy-paste code between mutable, const, and immutable functions? Yes, that's it's design, but it's not magic either. It makes it so that a single *implementation* can work as mutable or immutable. What you are asking for is actually 3 different implementations (3 different return types). At least, that's how I understood the issue. Maybe bring it up on learn to see if I'm wrong. That said, please think about your design, and what it means to have const/non-const overloads that return different types. > As you've described > (unless I'm misunderstanding), I should copy-paste > > @property auto foo() inout nothrow pure @safe { > return arr.map!(e => e.fun(this)); > } > > as mutable, const, and nothrow. Shouldn't this be something which should be > fixed with inout and/or templates themselves? Maybe there is a template solution, but (AFAIK) templates don't have the capability of conditionally tagging things as const or not. I'd have thought mixin templates could solve this, like this: //---- mixin template fooImpl() { auto foo() { return l(a); } } mixin fooImpl!(); const mixin fooImpl!(); immutable mixin fooImpl!(); //---- But apparently, the qualifiers are ignored, and this simply creates the same function 3 times. So I don't see anything other than string mixins :/ -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------