On 09/07/2015 04:53, Marvin Humphrey wrote:
In retrospect, I regret the Num inheritance hierarchy. I wish that instead,
we had only Boolean, Integer, and Float, matching the types available in JSON.
That wouldn't solve all our problems, it would just give us a different set of
problems -- but I feel like that set of problems is more appropriate for
Clownfish to have.
I agree. Here is a branch that implements most of your ideas.
https://github.com/nwellnhof/lucy-clownfish/commits/num_hierarchy
https://github.com/nwellnhof/lucy/commits/num_hierarchy
Execpt for:
* Integer, Float, and Boolean would all live in their own files rather than
in Num.cfh/Num.c.
Implementing Integer and Float in a single file allows to share some static
functions.
* Boolean, Integer, and Float would all be immutable.
Boolean is immutable already. Making Integer and Float immutable requires some
adjustments to Lucy's Inverter similar to the changes for immutable Strings.
This wouldn't impact much because the box types for numerics are infrequently
encountered in Clownfish-flavored C.
Yes, boxed objects are expensive anyway, so the additional overhead shouldn't
matter.
Nick