[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: math expressions (was: Re: Tail call elimination)
From: |
Paul Smith |
Subject: |
Re: math expressions (was: Re: Tail call elimination) |
Date: |
Thu, 28 May 2020 16:12:52 -0400 |
On Wed, 2020-05-27 at 13:47 -0500, Pete Dietl wrote:
> Technically, the C standard allows for machines which don't use 2's
> complement. So should we consider our LONG_MIN to be -2^63 + 1?
>
> Also, signed arithmetic overflow is undefined behavior, so should we
> also indicate that we have undefined behavior or should we use some
> function that reliably detects and wraps signed arithmetic?
>
> Bit shifting to the right with signed integers is undefined behavior
> too. Usually this is an arithmetic shift, but it's not guaranteed.
> Should we try to guarantee this with some function or should we leave
> this as undefined behavior?
It seems to me we have these choices:
Just perform the math that they ask us to perform and document that the
behavior is whatever the compiler that built make describes it to be.
Or, have the math implementation check for undefined behavior and make
it a fatal error. gnulib provides a number of macros which will check
for overflow, for example, that could be used to implement this.
I'm somewhat agnostic on the whole thing since I have a hard time
imagining a situation where it would ever be an issue in any makefile I
might want to write.
In general I prefer to get a real failure rather than undefined
behavior: however, the vast majority of compilers use 2's complement
math for signed values so while the standard leaves it undefined, _in
practice_ it's well-understood what the behavior will be. As a result
I don't have a strong opinion.
> Before I make my proposal, what do you think of supporting the
> following operators:
> +, -, /, *, not, and, or, comp, <<, >>
I'm not sure what comp is? Is this <=>?
Do we need shift? I mean I guess it doesn't hurt but you can always
use * and / instead :).
> Should the logical operators have english names or should they be C
> symbols like !, &, |, ~ ?
If we include bitwise operators I think we should use C symbols else
they may be confused for boolean operators; for example we have
$(and ...) and $(or ...) functions.
- Re: math expressions (was: Re: Tail call elimination), (continued)
- Re: math expressions (was: Re: Tail call elimination), Pete Dietl, 2020/05/25
- Re: math expressions (was: Re: Tail call elimination), Pete Dietl, 2020/05/25
- Re: math expressions (was: Re: Tail call elimination), Paul Smith, 2020/05/26
- Re: math expressions (was: Re: Tail call elimination), Pete Dietl, 2020/05/27
- Re: math expressions (was: Re: Tail call elimination), Pete Dietl, 2020/05/28
- Re: math expressions (was: Re: Tail call elimination), Jouke Witteveen, 2020/05/28
- Re: math expressions (was: Re: Tail call elimination), Paul Smith, 2020/05/28
- Re: math expressions (was: Re: Tail call elimination), Pete Dietl, 2020/05/28
- Re: math expressions (was: Re: Tail call elimination), Tim Murphy, 2020/05/28
- Re: math expressions (was: Re: Tail call elimination), Paul Smith, 2020/05/28
- Re: math expressions (was: Re: Tail call elimination),
Paul Smith <=
- Re: Tail call elimination, Paul Smith, 2020/05/18