Re: technology discussion → does the world need a "new" C ?

Liste des GroupesRevenir à cl c  
Sujet : Re: technology discussion → does the world need a "new" C ?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.c
Date : 05. Jul 2024, 20:46:38
Autres entêtes
Organisation : None to speak of
Message-ID : <87wmlzvfqp.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5
User-Agent : Gnus/5.13 (Gnus v5.13)
BGB <cr88192@gmail.com> writes:
On 7/5/2024 3:09 AM, Keith Thompson wrote:
BGB <cr88192@gmail.com> writes:
[...]
*1: While not exactly that rare, and can be useful, it is debatable if
  they add enough to really justify their complexity and relative
  semantic fragility. If using pointers, one almost invariably needs to
  fall back to doing "arr[y*N+x]" or similar anyways, so it is arguable
  that it could make sense to drop them and have people always do their
  multidimensional indexing manually.
>
Note that multidimensional indexing via multiple levels of pointer
indirection would not be effected by this.
[...]
Multidimensional arrays in C are not a distinct language feature.
They are simply arrays of arrays, and all operations on them follow
from operations on ordinary arrays and pointers.
Are you proposing (in this hypothetical new language) to add
an arbitrary restriction, so that arrays can have elements of
arithmetic, pointer, struct, etc. type, but not of array type?
I'm not sure I see the point.
 
>
As-is, the multidimensional arrays require the compiler to realize
that it needs to multiply one index by the product of all following
indices.
>
So, say:
  int a[4][4];
   int j, k, l;
   l=a[j][k];
>
Essentially needs to be internally translated to, say:
   l=a[j*4+k];
>
Eliminating multidimensional arrays eliminates the need for this
translation logic, and the need to be able to represent this case in
the typesystem handling logic (which is, as I see it, in some ways
very different from what one needs for a struct).

The C standard has just one normative paragraph that discusses
multidimensional arrays.  That paragraph is provided for clarity, but
could be removed without changing the language.

Multidimensional arrays require no work by the compiler that's not
already required for any other array type, particularly if you disallow
VLAs.  Every indexing operation requires multiplying the the index by
the size of the element type.

As Ben suggests, if you add a special case rule to disallow arrays of
arrays, programmers will simply wrap arrays in structures, achieving the
same generated code with more obfuscated source code.

Removing multidimensional arrays from a C-like language would require
adding an arbitrary restriction, not removing a feature.

There are probably some optimizations a compiler could perform for
multidimensional array indexing -- but if you want to simplify the
compiler, just don't do those optimizations.

[...]

I personally would hope that this language would *not* inherit C's
odd treatment of arrays and pointers.  If so, and if it supports
multidimensional arrays, they'd have to be defined differently than
the way they're defined in C.
 
>
The idea in this case was to make it so that:
  int[16];
Can be functionally identical to:
  int*
As far as most of the compiler's type-system handling is concerned. In
this case, one only needs to care about the size when reserving space
for the array.

No, arrays are not pointers.  As I'm sure you know, an expression of
array type is "converted" to a pointer to its initial element in most
but not all contexts; the exceptions are sizeof, unary "&", and a string
literal used to initialize an array object.  There are also special
rules about parameters that appear to be of array type.  Aside from
those rules, array types and pointer types are as distinct as, say,
structs and integers.

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Date Sujet#  Auteur
4 Jul 24 * technology discussion → does the world need a "new" C ?301aotto1968
5 Jul 24 +* Re: technology discussion → does the world need a "new" C ?298Lawrence D'Oliveiro
5 Jul 24 i`* Re: technology discussion → does the world need a "new" C ?297BGB
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?2Lawrence D'Oliveiro
5 Jul 24 i i`- Re: technology discussion → does the world need a "new" C ?1yeti
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?267Keith Thompson
5 Jul 24 i i+- Re: technology discussion → does the world need a "new" C ?1Lawrence D'Oliveiro
5 Jul 24 i i+* Re: technology discussion → does the world need a "new" C ?264BGB
5 Jul 24 i ii+* Re: technology discussion → does the world need a "new" C ?18Ben Bacarisse
5 Jul 24 i iii`* Re: technology discussion → does the world need a "new" C ?17BGB
6 Jul 24 i iii +* Re: technology discussion → does the world need a "new" C ?14Ben Bacarisse
6 Jul 24 i iii i+* Re: technology discussion → does the world need a "new" C ?9BGB
6 Jul 24 i iii ii+* Re: technology discussion → does the world need a "new" C ?2David Brown
6 Jul 24 i iii iii`- Re: technology discussion → does the world need a "new" C ?1BGB
7 Jul 24 i iii ii`* Re: technology discussion → does the world need a "new" C ?6Ben Bacarisse
7 Jul 24 i iii ii +* Re: technology discussion → does the world need a "new" C ?2Keith Thompson
7 Jul 24 i iii ii i`- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
7 Jul 24 i iii ii `* Re: technology discussion → does the world need a "new" C ?3BGB
7 Jul 24 i iii ii  `* Re: technology discussion → does the world need a "new" C ?2bart
7 Jul 24 i iii ii   `- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i iii i`* Re: technology discussion → does the world need a "new" C ?4Malcolm McLean
6 Jul 24 i iii i `* Re: technology discussion → does the world need a "new" C ?3BGB
6 Jul 24 i iii i  `* Re: technology discussion → does the world need a "new" C ?2bart
7 Jul 24 i iii i   `- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i iii `* Re: technology discussion → does the world need a "new" C ?2Janis Papanagnou
6 Jul 24 i iii  `- Re: technology discussion → does the world need a "new" C ?1BGB
5 Jul 24 i ii`* Re: technology discussion → does the world need a "new" C ?245Keith Thompson
6 Jul 24 i ii `* Re: technology discussion → does the world need a "new" C ?244Lawrence D'Oliveiro
6 Jul 24 i ii  +* Re: technology discussion → does the world need a "new" C ?228BGB
6 Jul 24 i ii  i+- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i ii  i+* Re: technology discussion → does the world need a "new" C ?6James Kuyper
6 Jul 24 i ii  ii`* Re: technology discussion → does the world need a "new" C ?5BGB
9 Jul 24 i ii  ii `* Re: technology discussion → does the world need a "new" C ?4David Brown
9 Jul 24 i ii  ii  `* Re: technology discussion → does the world need a "new" C ?3Michael S
9 Jul 24 i ii  ii   +- Re: technology discussion → does the world need a "new" C ?1David Brown
9 Jul 24 i ii  ii   `- Re: technology discussion → does the world need a "new" C ?1BGB
7 Jul 24 i ii  i`* Re: technology discussion → does the world need a "new" C ?220Keith Thompson
7 Jul 24 i ii  i +* Re: technology discussion → does the world need a "new" C ?215BGB
7 Jul 24 i ii  i i`* Re: technology discussion → does the world need a "new" C ?214James Kuyper
7 Jul 24 i ii  i i `* Re: technology discussion → does the world need a "new" C ?213BGB
8 Jul 24 i ii  i i  `* Re: technology discussion → does the world need a "new" C ?212James Kuyper
8 Jul 24 i ii  i i   `* Re: technology discussion → does the world need a "new" C ?211Kaz Kylheku
8 Jul 24 i ii  i i    +- Re: technology discussion → does the world need a "new" C ?1BGB
8 Jul 24 i ii  i i    +- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
8 Jul 24 i ii  i i    +* Re: technology discussion → does the world need a "new" C ?207James Kuyper
8 Jul 24 i ii  i i    i`* Re: technology discussion → does the world need a "new" C ?206BGB
9 Jul 24 i ii  i i    i `* Re: technology discussion → does the world need a "new" C ?205David Brown
9 Jul 24 i ii  i i    i  +* Re: technology discussion → does the world need a "new" C ?197bart
9 Jul 24 i ii  i i    i  i+* Re: technology discussion → does the world need a "new" C ?194Ben Bacarisse
9 Jul 24 i ii  i i    i  ii`* Re: technology discussion → does the world need a "new" C ?193bart
9 Jul 24 i ii  i i    i  ii +* Re: technology discussion → does the world need a "new" C ?184Ben Bacarisse
9 Jul 24 i ii  i i    i  ii i+* Re: technology discussion → does the world need a "new" C ?3BGB
10 Jul 24 i ii  i i    i  ii ii`* Re: technology discussion → does the world need a "new" C ?2Ben Bacarisse
10 Jul 24 i ii  i i    i  ii ii `- Re: technology discussion → does the world need a "new" C ?1BGB
9 Jul 24 i ii  i i    i  ii i`* Re: technology discussion → does the world need a "new" C ?180bart
9 Jul 24 i ii  i i    i  ii i +- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i i    i  ii i `* Re: technology discussion → does the world need a "new" C ?178Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i  `* Re: technology discussion → does the world need a "new" C ?177bart
10 Jul 24 i ii  i i    i  ii i   `* Re: technology discussion → does the world need a "new" C ?176Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i    +- Re: technology discussion → does the world need a "new" C ?1Thiago Adams
10 Jul 24 i ii  i i    i  ii i    +* Re: technology discussion → does the world need a "new" C ?167bart
10 Jul 24 i ii  i i    i  ii i    i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
10 Jul 24 i ii  i i    i  ii i    i+* Re: technology discussion → does the world need a "new" C ?54Tim Rentsch
10 Jul 24 i ii  i i    i  ii i    ii+* Re: technology discussion → does the world need a "new" C ?14Michael S
10 Jul 24 i ii  i i    i  ii i    iii+* Re: technology discussion → does the world need a "new" C ?8David Brown
11 Jul 24 i ii  i i    i  ii i    iiii`* Re: technology discussion → does the world need a "new" C ?7Michael S
11 Jul 24 i ii  i i    i  ii i    iiii `* Re: technology discussion → does the world need a "new" C ?6Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iiii  `* Re: technology discussion → does the world need a "new" C ?5Michael S
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 i ii  i i    i  ii i    iiii   +- Re: technology discussion → does the world need a "new" C ?1David Brown
11 Jul 24 i ii  i i    i  ii i    iiii   `- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
11 Jul 24 i ii  i i    i  ii i    iii+- Re: technology discussion → does the world need a "new" C ?1Kaz Kylheku
11 Jul 24 i ii  i i    i  ii i    iii`* Re: technology discussion → does the world need a "new" C ?4Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    iii `* Re: technology discussion → does the world need a "new" C ?3BGB
11 Jul 24 i ii  i i    i  ii i    iii  `* Re: technology discussion → does the world need a "new" C ?2Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    iii   `- Re: technology discussion → does the world need a "new" C ?1BGB
10 Jul 24 i ii  i i    i  ii i    ii`* Re: technology discussion → does the world need a "new" C ?39bart
10 Jul 24 i ii  i i    i  ii i    ii +* Re: technology discussion → does the world need a "new" C ?37Michael S
10 Jul 24 i ii  i i    i  ii i    ii i+* Re: technology discussion → does the world need a "new" C ?34bart
11 Jul 24 i ii  i i    i  ii i    ii ii+- Re: technology discussion → does the world need a "new" C ?1Michael S
11 Jul 24 i ii  i i    i  ii i    ii ii`* Re: technology discussion → does the world need a "new" C ?32Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    ii ii `* Re: technology discussion → does the world need a "new" C ?31bart
11 Jul 24 i ii  i i    i  ii i    ii ii  +* Re: technology discussion → does the world need a "new" C ?2Tim Rentsch
11 Jul 24 i ii  i i    i  ii i    ii ii  i`- Re: technology discussion → does the world need a "new" C ?1bart
11 Jul 24 i ii  i i    i  ii i    ii ii  `* Re: technology discussion → does the world need a "new" C ?28Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii ii   `* Re: technology discussion → does the world need a "new" C ?27bart
11 Jul 24 i ii  i i    i  ii i    ii ii    +* Re: technology discussion → does the world need a "new" C ?25Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii ii    i+* Re: technology discussion → does the world need a "new" C ?15bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii`* Re: technology discussion → does the world need a "new" C ?14David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii +* Re: technology discussion → does the world need a "new" C ?12bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i+* Re: technology discussion → does the world need a "new" C ?7David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii ii`* Re: technology discussion → does the world need a "new" C ?6bart
12 Jul 24 i ii  i i    i  ii i    ii ii    ii ii +* Re: technology discussion → does the world need a "new" C ?2bart
13 Jul 24 i ii  i i    i  ii i    ii ii    ii ii i`- Re: technology discussion → does the world need a "new" C ?1David Brown
13 Jul 24 i ii  i i    i  ii i    ii ii    ii ii `* Re: technology discussion → does the world need a "new" C ?3David Brown
17 Jul 24 i ii  i i    i  ii i    ii ii    ii ii  `* Re: technology discussion → does the world need a "new" C ?2Bart
17 Jul 24 i ii  i i    i  ii i    ii ii    ii ii   `- Re: technology discussion → does the world need a "new" C ?1David Brown
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i`* Re: technology discussion → does the world need a "new" C ?3Keith Thompson
12 Jul 24 i ii  i i    i  ii i    ii ii    ii i `* Re: technology discussion → does the world need a "new" C ?2James Kuyper
12 Jul 24 i ii  i i    i  ii i    ii ii    ii `- Re: technology discussion → does the world need a "new" C ?1BGB
11 Jul 24 i ii  i i    i  ii i    ii ii    i`* Re: technology discussion → does the world need a "new" C ?9bart
12 Jul 24 i ii  i i    i  ii i    ii ii    `- Re: technology discussion → does the world need a "new" C ?1Thiago Adams
10 Jul 24 i ii  i i    i  ii i    ii i+- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
11 Jul 24 i ii  i i    i  ii i    ii i`- Re: technology discussion → does the world need a "new" C ?1James Kuyper
11 Jul 24 i ii  i i    i  ii i    ii `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i i    i  ii i    i+* Re: technology discussion → does the world need a "new" C ?2James Kuyper
11 Jul 24 i ii  i i    i  ii i    i`* Re: technology discussion → does the world need a "new" C ?109Ben Bacarisse
10 Jul 24 i ii  i i    i  ii i    `* Re: technology discussion → does the world need a "new" C ?7Janis Papanagnou
10 Jul 24 i ii  i i    i  ii `* Re: technology discussion → does the world need a "new" C ?8Kaz Kylheku
9 Jul 24 i ii  i i    i  i+- Re: technology discussion → does the world need a "new" C ?1David Brown
9 Jul 24 i ii  i i    i  i`- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
9 Jul 24 i ii  i i    i  +- Re: technology discussion → does the world need a "new" C ?1Michael S
9 Jul 24 i ii  i i    i  `* Re: technology discussion → does the world need a "new" C ?6BGB
9 Jul 24 i ii  i i    `- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
10 Jul 24 i ii  i `* Re: technology discussion → does the world need a "new" C ?4Lawrence D'Oliveiro
6 Jul 24 i ii  +* Re: technology discussion → does the world need a "new" C ?9James Kuyper
7 Jul 24 i ii  `* Re: technology discussion → does the world need a "new" C ?6Keith Thompson
6 Jul 24 i i`- Re: technology discussion → does the world need a "new" C ?1Lawrence D'Oliveiro
5 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?26bart
5 Jul 24 i `- Re: technology discussion → does the world need a "new" C ?1lexi hale
7 Jul 24 `* Re: technology discussion → does the world need a "new" C ?2Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal