bug-make
[Top][All Lists]
Advanced

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

Re: math expressions (was: Re: Tail call elimination)


From: Tim Murphy
Subject: Re: math expressions (was: Re: Tail call elimination)
Date: Thu, 28 May 2020 23:02:57 +0000



On Thu, 28 May 2020 at 22:07, Pete Dietl <petedietl@gmail.com> wrote:
Upon taking a look at gnulib, I found that they have arithmetic wrap
functions which guarantee wrapping.
We can use these functions to guarantee that overflow will just wrap around.

Let's leave the shift operators out for now.

comp is for complement. ~

In most scheme implementations, providing only one operand to the
arithmetic functions
just returns that argument, aside from subtraction, which negates the argument.

Once again I am aiming for the single argument syntax of $(math ...)

Interestingly, in Guile, (+) and (*) return 1, but (/) and (-) return
errors about invalid number of arguments.
Personally, I think no operands should result in an error.

I think that would save people from horrible bugs that would otherwise be hidden, so yes.

Integer maths is important at the language level - it will enable algorithms that weren't possible before e.g. dividing a list into equal halves or a for-loop for which we also need a function that generates a range).  To me this seems to be on a higher level of importance compared to bit manipulation.

Tim

reply via email to

[Prev in Thread] Current Thread [Next in Thread]