Re: Interval Comparisons

Liste des GroupesRevenir à cl c 
Sujet : Re: Interval Comparisons
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.c
Date : 06. Jun 2024, 20:48:42
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3t0aa$1k8ck$2@dont-email.me>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
On 05/06/2024 02:30, Lawrence D'Oliveiro wrote:
On Wed, 5 Jun 2024 00:22:36 +0100, bart wrote:
 
On 05/06/2024 00:12, Lawrence D'Oliveiro wrote:
>
On Tue, 4 Jun 2024 11:41:54 -0000 (UTC), Blue-Maned_Hawk wrote:
>
i think that we need not worsen the matter with new ternary operators.
>
These are not ternary operators.
>
So what are they?
 A special case in the syntax rules for the comparison operators
<https://docs.python.org/3/reference/expressions.html#comparisons>.
 
I've implemented them several times, and found they really need to be
treated as a special kind of n-ary opterator.
 Remember, Python allows users to define custom overloads for the standard
operators. For comparisons, these functions always take two operands, and
the compiler takes care of invoking them correctly to handle interval
comparisons.
Well, for these 3 lines in my scripting language:
   if a = b then end             # universal
   if a = b < c then end         # chained (like Python, unlike C)
   if (a = b) < c then end       # emulate C behaviour
These are the ASTs produced (2: is the empty True branch; 3: would be for the 'else' branch, not present here):
- 1 if:
- - 1 eq:
- - - 1 name: a
- - - 2 name: b
- - 2 block:
- 1 if:
- - 1 cmpchain: eq lt
- - - 1 name: a
- - - 1 name: b
- - - 1 name: c
- - 2 block:
- 1 if:
- - 1 lt:
- - - 1 eq:
- - - - 1 name: a
- - - - 2 name: b
- - - 2 name: c
- - 2 block:
Notice the middle one is one linear group with N operands and N-1 comparisons.
No operator overloads are allowed, but if they were, it would still work, but a comparison operator would be required to return True or False from its two operands. It would be unwise for it to return a string for example.

Date Sujet#  Auteur
4 Jun 24 * Interval Comparisons44Lawrence D'Oliveiro
4 Jun 24 +* Re: Interval Comparisons14David Brown
4 Jun 24 i`* Re: Interval Comparisons13Mikko
4 Jun 24 i +* Re: Interval Comparisons10David Brown
4 Jun 24 i i+* Re: Interval Comparisons8bart
4 Jun 24 i ii+* Re: Interval Comparisons6David Brown
4 Jun 24 i iii+* Re: Interval Comparisons2bart
4 Jun 24 i iiii`- Re: Interval Comparisons1David Brown
4 Jun 24 i iii`* Re: Interval Comparisons3bart
4 Jun 24 i iii `* Re: Interval Comparisons2Michael S
4 Jun 24 i iii  `- Re: Interval Comparisons1bart
5 Jun 24 i ii`- Re: Interval Comparisons1Lawrence D'Oliveiro
4 Jun 24 i i`- Re: Interval Comparisons1Mikko
4 Jun 24 i +- Re: Interval Comparisons1Janis Papanagnou
4 Jun 24 i `- Re: Interval Comparisons1Keith Thompson
4 Jun 24 +- Re: Interval Comparisons1bart
4 Jun 24 +* Re: Interval Comparisons3Thiago Adams
4 Jun 24 i+- Re: Interval Comparisons1Bonita Montero
5 Jun 24 i`- Re: Interval Comparisons1Keith Thompson
4 Jun 24 `* Re: Interval Comparisons25Blue-Maned_Hawk
4 Jun 24  +- Re: Interval Comparisons1Michael S
5 Jun 24  `* Re: Interval Comparisons23Lawrence D'Oliveiro
5 Jun 24   `* Re: Interval Comparisons22bart
5 Jun 24    `* Re: Interval Comparisons21Lawrence D'Oliveiro
6 Jun 24     `* Re: Interval Comparisons20bart
7 Jun 24      `* Re: Interval Comparisons19Lawrence D'Oliveiro
7 Jun 24       `* Re: Interval Comparisons18bart
7 Jun 24        `* Re: Interval Comparisons17Lawrence D'Oliveiro
7 Jun 24         `* Re: Interval Comparisons16Keith Thompson
7 Jun 24          +- Re: Interval Comparisons1Lawrence D'Oliveiro
7 Jun 24          `* Re: Interval Comparisons14David Brown
7 Jun 24           +* Re: Interval Comparisons4Keith Thompson
7 Jun 24           i`* Re: Interval Comparisons3David Brown
7 Jun 24           i `* Re: Interval Comparisons2Keith Thompson
8 Jun 24           i  `- Re: Interval Comparisons1David Brown
7 Jun 24           +* Re: Interval Comparisons8bart
7 Jun 24           i+* Re: Interval Comparisons2Lawrence D'Oliveiro
7 Jun 24           ii`- Re: Interval Comparisons1Michael S
7 Jun 24           i`* Re: Interval Comparisons5David Brown
7 Jun 24           i `* Re: Interval Comparisons4bart
9 Jun 24           i  `* Re: Interval Comparisons3David Brown
10 Jun 24           i   `* Re: Interval Comparisons2bart
10 Jun 24           i    `- Re: Interval Comparisons1David Brown
7 Jun 24           `- Re: Interval Comparisons1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal