[Issue 11188] std.math.abs fails for shared, const or immutable BigInt types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 10 17:33:43 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11188



--- Comment #5 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2013-10-10 17:33:40 PDT ---
(In reply to comment #3)
> In this case, you need inout, because you want to propagate the incoming
> qualifiers to the output: if x>=0, then you're returning x again, so the return
> type needs to carry whatever qualifiers x had on entering the function.
> Everything implicitly converts to const, of course, but it would suck if you
> returned const and the caller passed in unqual, and now after calling abs he
> can't modify the BigInt anymore!

I wasn't talking about returning const, but about the _input_ to the function.

I'm not actually certain you do always want to propagate the qualifiers to the
output -- I may want to be able to do:

    immutable BigInt x = -345678;
    BigInt xAbs = abs(x);

... or is inout sensitive to things like this?  In any case, bear in mind that
abs doesn't always guaranteed to return the same type -- if you give it (say) a
cfloat or an ifloat, it'll return a real.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list