Deutsch   English   Français   Italiano  
<v477n3$h516$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: Interval Comparisons
Date: Mon, 10 Jun 2024 17:56:19 +0200
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <v477n3$h516$1@dont-email.me>
References: <v3merq$b1uj$1@dont-email.me>
 <pan$63fde$3c88716e$c61af1ee$d0a27c97@invalid.invalid>
 <v3o706$kfrm$2@dont-email.me> <v3o7jr$ki9u$1@dont-email.me>
 <v3of4h$pbb1$1@dont-email.me> <v3t0aa$1k8ck$2@dont-email.me>
 <v3tene$1n5ge$1@dont-email.me> <v3tlkj$1of9j$1@dont-email.me>
 <v3tqji$1t2fv$1@dont-email.me> <87bk4dz9ve.fsf@nosuchdomain.example.com>
 <v3ujg5$20s0s$1@dont-email.me> <v3unc7$20up1$1@dont-email.me>
 <v3uq8u$21i37$2@dont-email.me> <v3utuh$22afr$1@dont-email.me>
 <v443gb$3f1d5$1@dont-email.me> <v476bo$h1eu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 10 Jun 2024 17:56:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c8fdaca8f4676d2822b9c14d4f88eea0";
	logging-data="562214"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+2Nw1iNHMnXhZeGlQa2sKg8vTnPKsrNLg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:7HfKgrlKNP1T2/KCYPIW/H+EQCA=
In-Reply-To: <v476bo$h1eu$1@dont-email.me>
Content-Language: en-GB
Bytes: 4015

On 10/06/2024 17:33, bart wrote:
> On 09/06/2024 12:26, David Brown wrote:
>> On 07/06/2024 14:20, bart wrote:
>>> On 07/06/2024 12:17, David Brown wrote:


>> If that is your intent, then fair enough.  But I think that is an 
>> unusual intent.
> 
> Really,  checking that A and B both have the same value X is that unusual?

No.  But checking that A and B have the same value, then checking that 
one of them as the same value as a constant X, is - I would say - 
definitely an unusual way to think about things.  It is more natural to 
check if A is equal to X, and if B is equal to X.

You seem to disagree with that.  Fair enough, it is a subjective opinion.

>>
>> I don't think it is fair to claim particular ways of writing these 
>> things are always clearer, or better, or uglier, or unclear - it will 
>> depend on the rest of the language, and how the code is used.  But in 
>> general I think it helps to write code that follows the logic of what 
>> the writer really means, rather than alternative constructions that 
>> give the same result.
> 
> Using function-like syntax is OK when you have the same operator between 
> multiple terms. 'rising' could have '<' or '<='.

Yes.  I think that is almost certainly what you would want, except in 
the case of checking if a value is in a half-open interval.  I would be 
happy with an "in" operator and ranges of some sort for that case.

> 
> All-equal would have the same operator too, but it looks clunkier, and a 
> bit over-the-top:
> 
>     a = b                2 terms
>     all_equal(a, b, c)   3 terms using your feature
>     a = b = c            3 terms using chained ops
> 
>     rising(a, b, c)      Using your other feature
>     a <= b <= c          Using the same chained-op feature
> 

I guess a lot of this ends up as a matter of taste.

> Your solution requires a heavyweight language feature. It also looks 
> like it will generate a lot of intermediate code that will need a 
> heavyweight optimiser to tear down again.
> 

I place approximately zero weight on requirements for code generators to 
be optimising.  It is irrelevant to the user - it only matters to the 
implementer of the tools.  It does have to be /possible/ to implement 
the feature, but it does not matter if the compiler has to optimise well 
to make it efficient.