Ruud H.G. van Tol on Tue, 03 Jan 2023 12:32:43 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Question on using eval...



On 2023-01-03 12:11, Bill Allombert wrote:
On Tue, Jan 03, 2023 at 10:43:48AM +0100, Ruud H.G. van Tol wrote:
The "symbolic equality" also needs to be defined first.

? f(a,b,c) = (a / b) + c;
? g(a,b,c) = a / b + c;
? h(a,b,c) = c + a / b;
? print([f == g, f == h, g == h, g == f, f === g]);
[1, 0, 0, 1, 1]
Indeed, comparing closures means comparing the bytecode generated by the internal compiler.
The parser ignores useless parentheses so f and g are identical.

How human ;)

I would prefer it to (optionally?) generate the same bytecode
(and maybe also a function-fingerprint or -identity)
for either f,g,h though, or is that not a worthy goal?


This assumes ignoring spurious rounding effects,
but I think that is only good,
as there are always cleaner ways to code those in.

-- Ruud