develooper Front page | perl.perl5.porters | Postings from August 2021

Re: Pre-RFC decimal data type

Thread Previous | Thread Next
Darren Duncan
August 6, 2021 00:09
Re: Pre-RFC decimal data type
Message ID:
On 2021-08-05 5:03 p.m., Darren Duncan wrote:
> On 2021-08-05 9:53 a.m., Harald Jörg wrote:
>> To add to the Java misery: If you retrieve a Java BigDecimal, e.g. from
>> a database, and want to add one, you need to create a new object:
>> value = value.add(new BigDecimal(1)).  Compare that to Perl's $value++.
> I would consider creating a new object to be a feature rather than a misery. 
> Numbers should be immutable. -- Darren Duncan

Also your $value++ example isn't the same thing, it isn't mutating the object, 
its assigning a new thing to $value.

If someone had this:

   $v1 = 42;
   $v2 = $v1;

Then $v2 would still point to 42.

I would expect/desire even with bignum libraries, that adding one to $v1 would 
NOT change the value in $v2, same as with small numbers, but if the number 
object is mutable then it would.

-- Darren Duncan

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About