Hello Albert
I'm a bit confused about the built-in mixed arithmetic, more preicsely the automated evaluation to "doubles". Although I've been trying hard on finding a method to inhibit such evaluations (without using quotes), it seems impossible (even without primitives, prelude ...):
> pure -n -i
__ \ | | __| _ \ Pure 0.68 (i686-w64-mingw32)
| | | | | __/ Copyright (c) 2008-2018 by Albert Graef
.__/ \__,_|_| \___| (Type 'help' for help, 'help copying'
_| for license information.)
> foo (x/y) = x:y;
> foo (2/3);
foo 0.666666666666667
> namespace bar;
> qq (x/y) = [x,y];
> qq (7/8);
bar::qq 0.875
>
Usually, when clearing the operators [*,/,^,+,-], it works well, however, one may never be sure.
Will it be difficult to provide a switch that inhibits evaluation of "exactp" expressions (?), that is for instance:
$>pure -i -q
> 2/3;
0.666666666666667 // prefer: 2/3
> clear /
> 2/3;
2/3
> (2/3)*x;
0.666666666666667*x // dito
> clear *
> (2/3)*x;
2/3*x
> ppp (2/3);
ppp (2/3)
> qqq (x/y) = x:y;
> qqq (2/3);
qqq 0.666666666666667 // dito
>
I had a look into interpreter.cc:
Value *interpreter::builtin_codegen(expr x)
{
// handle special cases which should be inlined for efficiency: mixed
// arithmetic, comparisons, logical ops using unboxed integer and floating
// point values
and - just a guess - have been thinking that it could be done somewhere here? Before filling out a feature request, what do you think?
Best wishes
Kurt