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: Sam Kendall
Subject: Re: math expressions (was: Re: Tail call elimination)
Date: Mon, 25 May 2020 12:07:29 -0400

I'd like to raise some questions that I think any proposal ought to answer. I'll assume a straw man proposal: there's one function, and it takes one of the following forms:

$(math OPERATOR,VALUE1,VALUE2)
$(math OPERATOR,VALUE1)

A binary operator (first form) is one of + - * and /. The only unary operator is "-". There might also be equality and relational operators. A value is an optional "-" followed by one or more decimal digits. It represents a 64-bit signed integer.

I'd like to see a proposal that's as simple as possible and that includes use cases. I also like fatal errors in dubious cases, because you can always relax such a rule later and still be backward compatible.

---

Can an input include whitespace? If so, where?

What happens with an unparseable input such as empty string, foo, or 0.5? Precedent suggests a fatal error. For example, any of those strings as the first arg to $(word ) produces a fatal error.

What happens with an out-of-range input such as 9223372036854775808?

What happens upon overflow, e.g., $(math +,9223372036854775807,1)?

How do you input the most negative integer? In other words, is -9223372036854775808 a valid value?

What happens upon division by zero?

What are the rounding rules for division?

If you have relational or equality operators, what does the boolean result look like? If the result is 1 for true and 0 for false, then you get a bad surprise: $(if $(math =,5,6),yes) expands to yes. If the answer is some nonempty string for true and empty string for false, then you can't do math on the result because it isn't a number. I think this has come up before in the discussion.

--Sam

reply via email to

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