The "no gc" crowd
Sean Kelly
sean at invisibleduck.org
Thu Oct 10 11:28:29 PDT 2013
On Oct 10, 2013, at 11:21 AM, Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> wrote:
> On 10/10/13 19:46, Sean Kelly wrote:
>> As for const / immutable, I guess I don't see this as such an issue because I've been dealing with it in C++ for so long. You either have to commit 100% to using const attributes or not use them at all. Anything in between is fraught with problems.
>
> Well, the problem is essentially that you can have a function like:
>
> void foo(int i) { ... }
>
> ... and if you pass it an immutable or const int, this is not a problem, because you're passing by value.
>
> But now try
>
> void foo(BigInt i) { ... }
>
> ... and it won't work when passed a const/immutable variable, even though again you're passing by value. That's not nice, not intuitive, and generally speaking makes working with complex data types annoying.
>
> It's why, for example, std.math.abs currently works with BigInt but not with const or immutable BigInt -- which is very irritating indeed.
Isn't BigInt a struct? I'd expect it to work via copying just like concrete types.
More information about the Digitalmars-d
mailing list