The "no gc" crowd

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Oct 10 11:21:12 PDT 2013


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.


More information about the Digitalmars-d mailing list