Project

General

Profile

Design #1606

Updated by John Abbott almost 3 years ago

While improving/correcting @binomial@ (see issue #1605) I noticed that many functions have a "funny" return type, namely *@const BigInt@* where one might have expected just *@BigInt@*.

There is an interesting discussion at @https://stackoverflow.com/questions/12051012/should-i-return-const-objects@
where it is pointed out that returning @const@ objects prevent use of move semantics (which require non-@const@ objects).

We originally used @const@ to block users from doing silly things such as @(a+b)++@ or even @(a+b) = 1;@ *[assignment!]* @(a+b)++@.
However, since @const@ now prevent use of move-semantics, it could thus force the
compiler to make copies of values where one might expect/hope that no copy was needed.

I propose now to remove most/all of these @const@ qualifiers on return types.

Back