dartist / dart-bignum

Other
14 stars 11 forks source link

Constant BigInteger predefs are not defined as const #25

Closed stevenroose closed 8 years ago

stevenroose commented 10 years ago

Is there a reason why the predefined BigIntegers like BigInteger.ZERO are not defined as const? In fact they are constant and it would be practical if they would be defined as such.

Being constant is a requirement for, a.o., using them as default values for method attributes.

I know it is a hassle to define them as constant because it requires all fields to be final, but I'm just wondering if you considered trying and concluded it is not possible or worth the effort or that you either didn't think about it.

adam-singer commented 10 years ago

Honestly its probably a more historical reason then structural. If you feel up to it sounds like nice PR to accept

stevenroose commented 10 years ago

I'm trying this now, but - I'm sorry to say - the code really looks like a mess. I'm only looking at it for a few minutes and I found unused variables, instance variables that never change so could/should be static, static variables that are changed every time a new instance is made (-> really asks for synchronisation issues if two instances are changing them to different values). I guess this is ported from JS? The reason may be that JS doesn't have static code. Did you look into a Java implementation as well?

I'm just gonna try to get the constant constructors working, but hopefully I'm getting to understand what's going on in the meantime; be it a little bit.

stevenroose commented 8 years ago

This ended up impossible to do :)