Re: Recursion, Yo

Liste des GroupesRevenir à l c 
Sujet : Re: Recursion, Yo
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.c
Date : 15. Apr 2024, 21:24:02
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uvjusj$ev88$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Mozilla Thunderbird
On 15/04/2024 20:00, Keith Thompson wrote:
Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
On 14.04.2024 02:29, Michael S wrote:
<Algol 68 code elided>
It looks closer to C than to Pascal, i.e. pointer can point to any
object rather than just to dynamically allocated object.
>
The major difference is that they are closely bound to the type.
In that respect they are more like Pascal pointers. C pointers
open the can of issues with arithmetic on pointer values. You
don't find that in Pascal or Algol 68.
[...]
>
How are C pointers not "closely bound to the type"?
>
   int i = 42;
   memcpy(&i, &(float){3.14}, sizeof i);
   printf("%d\n", i);
>
That looks like a pretty loose association between pointer and object
type to me.  This is not an accident or an unintended loophole.  It's by
design.
>
Certainly every pointer value in C has an associated type, but the
intention is that this association can be changed by pointer type
conversion as needed.
>
You often /have/ to make us of this.  For example, when calling qsort,
you will usually change the association between the pointer and the
pointed-to type (void) in order to do the comparison.  And C does not
even insist that you change it back to the original pointed-to type as
you can legally write a comparison function for, say, float data that
uses the representation as "raw" bytes.
 OK.  The way I'd describe it is that C (non-void) pointers *are*
"closely bound to the type", but in addition C provides operations,
particularly pointer casts and implicit conversions to and from void*,
that can override that binding.
 Janis mentioned pointer arithmetic.  I wouldn't say that overrides the
type binding; it merely provides a set of operations, that some other
languages lack, for constructing a pointer value from another pointer
value.  I don't know whether Janis meant that to be an example of not
being closely bound to the type, or as a distinct statement.
Implicit in every C non-void object pointer, is that it points to an element of an array, so that you access neighbouring elements via P+1, P-2, ++P and so on.
That is the case whether or not P actually points within such a sequence.
That assumption appears to be missing from those other languages.
C itself doesn't seem that bothered; it just treats any isolated object that a pointer refers to, as though it was part of an imaginary 1-element array.
Then any attempt to refer beyond it via pointer arithmetic, is a mere bounds error. But it's a bit more serious than that. It's like treating *NULL as a bounds error, because it might be a few MB away from the nearest valid object.
(My own lower level language allows similar pointer arithmetic. But it doesn't allow P[i] syntax; pointers and arrays are more distinct and therefore safer.
With an older dynamic language, pointers had a length attribute attached. So that (IIRC) single targets had a length of 1 so pointer arithmetic was limited.)

Date Sujet#  Auteur
7 Apr 24 * Recursion, Yo102Lawrence D'Oliveiro
7 Apr 24 +* Re: Recursion, Yo100fir
9 Apr 24 i`* Re: Recursion, Yo99Janis Papanagnou
9 Apr 24 i +* Re: Recursion, Yo7Lawrence D'Oliveiro
9 Apr 24 i i+* Re: Recursion, Yo5Janis Papanagnou
9 Apr 24 i ii`* Re: Recursion, Yo4Ben Bacarisse
9 Apr 24 i ii `* Re: Recursion, Yo3Janis Papanagnou
9 Apr 24 i ii  `* Re: Recursion, Yo2Keith Thompson
10 Apr 24 i ii   `- Re: Recursion, Yo1Janis Papanagnou
9 Apr 24 i i`- Re: Recursion, Yo1bart
9 Apr 24 i `* Re: Recursion, Yo91Ben Bacarisse
9 Apr 24 i  +- Re: Recursion, Yo1Ben Bacarisse
10 Apr 24 i  `* Re: Recursion, Yo89Lawrence D'Oliveiro
10 Apr 24 i   +- Re: Recursion, Yo1Chris M. Thomasson
10 Apr 24 i   +* Re: Recursion, Yo86David Brown
10 Apr 24 i   i+* Re: Recursion, Yo84Lawrence D'Oliveiro
10 Apr 24 i   ii`* Re: Recursion, Yo83David Brown
10 Apr 24 i   ii +* Re: Recursion, Yo73bart
10 Apr 24 i   ii i+* Re: Recursion, Yo71David Brown
11 Apr 24 i   ii ii`* Re: Recursion, Yo70Lawrence D'Oliveiro
11 Apr 24 i   ii ii +* Re: Recursion, Yo4Kaz Kylheku
11 Apr 24 i   ii ii i`* Heh heh... (Was: Recursion, Yo)3Kenny McCormack
11 Apr 24 i   ii ii i `* Re: Heh heh... (Was: Recursion, Yo)2Kaz Kylheku
11 Apr 24 i   ii ii i  `- Re: Heh heh... (Was: Recursion, Yo)1Kenny McCormack
11 Apr 24 i   ii ii `* Re: Recursion, Yo65David Brown
11 Apr 24 i   ii ii  +* Re: Recursion, Yo62Kaz Kylheku
11 Apr 24 i   ii ii  i+- Re: Recursion, Yo1David Brown
12 Apr 24 i   ii ii  i`* Re: Recursion, Yo60Lawrence D'Oliveiro
12 Apr 24 i   ii ii  i +* Re: Recursion, Yo2Kaz Kylheku
12 Apr 24 i   ii ii  i i`- Re: Recursion, Yo1Dan Cross
12 Apr 24 i   ii ii  i `* Re: Recursion, Yo57Janis Papanagnou
12 Apr 24 i   ii ii  i  +* Re: Recursion, Yo6David Brown
12 Apr 24 i   ii ii  i  i`* Re: Recursion, Yo5Janis Papanagnou
12 Apr 24 i   ii ii  i  i +* Re: Recursion, Yo3David Brown
13 Apr 24 i   ii ii  i  i i`* Re: Recursion, Yo2Janis Papanagnou
13 Apr 24 i   ii ii  i  i i `- Re: Recursion, Yo1David Brown
13 Apr 24 i   ii ii  i  i `- Re: Recursion, Yo1Lawrence D'Oliveiro
12 Apr 24 i   ii ii  i  +* Re: Recursion, Yo45Lawrence D'Oliveiro
12 Apr 24 i   ii ii  i  i`* Re: Recursion, Yo44Janis Papanagnou
12 Apr 24 i   ii ii  i  i +- Re: Recursion, Yo1bart
13 Apr 24 i   ii ii  i  i `* Re: Recursion, Yo42Lawrence D'Oliveiro
13 Apr 24 i   ii ii  i  i  +* Re: Recursion, Yo14Michael S
14 Apr 24 i   ii ii  i  i  i+* Re: Recursion, Yo11Ben Bacarisse
14 Apr 24 i   ii ii  i  i  ii`* Re: Recursion, Yo10Michael S
15 Apr 24 i   ii ii  i  i  ii `* Re: Recursion, Yo9Janis Papanagnou
15 Apr 24 i   ii ii  i  i  ii  `* Re: Recursion, Yo8Keith Thompson
15 Apr 24 i   ii ii  i  i  ii   `* Re: Recursion, Yo7Ben Bacarisse
15 Apr 24 i   ii ii  i  i  ii    `* Re: Recursion, Yo6Keith Thompson
15 Apr 24 i   ii ii  i  i  ii     +* Re: Recursion, Yo2bart
15 Apr 24 i   ii ii  i  i  ii     i`- Re: Recursion, Yo1Ben Bacarisse
15 Apr 24 i   ii ii  i  i  ii     `* Re: Recursion, Yo3Janis Papanagnou
15 Apr 24 i   ii ii  i  i  ii      +- Re: Recursion, Yo1Janis Papanagnou
15 Apr 24 i   ii ii  i  i  ii      `- Re: Recursion, Yo1Keith Thompson
14 Apr 24 i   ii ii  i  i  i`* Re: Recursion, Yo2Lawrence D'Oliveiro
14 Apr 24 i   ii ii  i  i  i `- Re: Recursion, Yo1Keith Thompson
13 Apr 24 i   ii ii  i  i  `* Re: Recursion, Yo27Janis Papanagnou
14 Apr 24 i   ii ii  i  i   `* Re: Recursion, Yo26Lawrence D'Oliveiro
14 Apr 24 i   ii ii  i  i    `* Re: Recursion, Yo25Ben Bacarisse
14 Apr 24 i   ii ii  i  i     +* Re: Recursion, Yo2bart
14 Apr 24 i   ii ii  i  i     i`- Re: Recursion, Yo1Ben Bacarisse
15 Apr 24 i   ii ii  i  i     `* Re: Recursion, Yo22Lawrence D'Oliveiro
15 Apr 24 i   ii ii  i  i      +* Re: Recursion, Yo20Chris M. Thomasson
15 Apr 24 i   ii ii  i  i      i+* Re: Recursion, Yo5Ben Bacarisse
16 Apr 24 i   ii ii  i  i      ii`* Re: Recursion, Yo4Lawrence D'Oliveiro
17 Apr 24 i   ii ii  i  i      ii `* Re: Recursion, Yo3Ben Bacarisse
18 Apr 24 i   ii ii  i  i      ii  `* Re: Recursion, Yo2Lawrence D'Oliveiro
22 Apr 24 i   ii ii  i  i      ii   `- Re: Recursion, Yo1Janis Papanagnou
15 Apr 24 i   ii ii  i  i      i`* Re: Recursion, Yo14Janis Papanagnou
16 Apr 24 i   ii ii  i  i      i +* Re: Recursion, Yo2Lawrence D'Oliveiro
22 Apr 24 i   ii ii  i  i      i i`- Re: Recursion, Yo1Janis Papanagnou
16 Apr 24 i   ii ii  i  i      i `* Re: Recursion, Yo11Michael S
19 Apr 24 i   ii ii  i  i      i  +* Re: Recursion, Yo9Tim Rentsch
19 Apr 24 i   ii ii  i  i      i  i+* Re: Recursion, Yo4bart
20 Apr 24 i   ii ii  i  i      i  ii`* Re: Recursion, Yo3Ben Bacarisse
20 Apr 24 i   ii ii  i  i      i  ii +- Re: Recursion, Yo1Keith Thompson
20 Apr 24 i   ii ii  i  i      i  ii `- Re: Recursion, Yo1Kaz Kylheku
19 Apr 24 i   ii ii  i  i      i  i+- Re: Recursion, Yo1Keith Thompson
19 Apr 24 i   ii ii  i  i      i  i+* Re: Recursion, Yo2Keith Thompson
20 Apr 24 i   ii ii  i  i      i  ii`- Re: Recursion, Yo1Tim Rentsch
20 Apr 24 i   ii ii  i  i      i  i`- Re: Recursion, Yo1Tim Rentsch
22 Apr 24 i   ii ii  i  i      i  `- Re: Recursion, Yo1Janis Papanagnou
15 Apr 24 i   ii ii  i  i      `- Re: Recursion, Yo1Ben Bacarisse
12 Apr 24 i   ii ii  i  +* Re: Recursion, Yo4bart
12 Apr 24 i   ii ii  i  i+* Re: Recursion, Yo2Janis Papanagnou
12 Apr 24 i   ii ii  i  ii`- Re: Recursion, Yo1bart
13 Apr 24 i   ii ii  i  i`- Re: Recursion, Yo1Keith Thompson
13 Apr 24 i   ii ii  i  `- Re: Recursion, Yo1Tim Rentsch
11 Apr 24 i   ii ii  `* Re: Recursion, Yo2Keith Thompson
12 Apr 24 i   ii ii   `- Re: Recursion, Yo1David Brown
14 Apr 24 i   ii i`- Re: Recursion, Yo1fir
10 Apr 24 i   ii +- Re: Recursion, Yo1Janis Papanagnou
10 Apr 24 i   ii +* Re: Recursion, Yo2Kaz Kylheku
10 Apr 24 i   ii i`- Re: Recursion, Yo1David Brown
11 Apr 24 i   ii +* Re: Recursion, Yo2Lawrence D'Oliveiro
12 Apr 24 i   ii i`- Re: Recursion, Yo1Ben Bacarisse
11 Apr 24 i   ii `* Re: Recursion, Yo4Lawrence D'Oliveiro
11 Apr 24 i   ii  +- Re: Recursion, Yo1Kaz Kylheku
11 Apr 24 i   ii  `* Re: Recursion, Yo2David Brown
11 Apr 24 i   ii   `- Re: Recursion, Yo1Lawrence D'Oliveiro
10 Apr 24 i   i`- Re: Recursion, Yo1Kaz Kylheku
10 Apr 24 i   `- Re: Recursion, Yo1Tim Rentsch
9 Apr 24 `- Re: Recursion, Yo1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal