Article View: comp.lang.misc
Article #2335Re: Pointers
From: Barry Margolin
Date: Fri, 06 Nov 1992 16:20
Date: Fri, 06 Nov 1992 16:20
33 lines
2019 bytes
2019 bytes
In article <1992Nov5.184831.16328@newshost.lanl.gov> jlg@cochiti.lanl.gov (J. Giles) writes:
>C has actually committed two sins against array users - both as a
>result of this coercion to pointer. First, it is not notationally
>convenient in C to program procedures which handle variable sized
>conformable arrays. Second, the coercion to pointer makes it
>impossible for the C compiler to *locally* determine whether
>incoming pointers are aliased. If the user were offered a choice,
>then he could declare the incoming arguments as pointers if he
>wanted to *allow* aliasing, and he could declare them as arrays
>(with or without variable dimensions) when he wanted to disallow
>aliasing.
I don't think either of these sins is related to its array->pointer
coercion feature.
The problem with variable-sized multidimensional arrays is due to the fact
that C includes interior array dimensions as part of the static type of an
array. Note that GCC provides variable-sized arrays as an extension, using
the intuitive notation.
And it's possible to have aliasing without pointer variables. Fortran has
this problem because parameters are passed by reference -- their solution
was simply to legislate that programs are not permitted to pass array
parameters (or is it all parameters) in such a fashion that such aliases
would occur. It's not possible to detect this statically in the general
case.
--
Barry Margolin
System Manager, Thinking Machines Corp.
barmar@think.com {uunet,harvard}!think!barmar
Technical Details
Message-ID:
<1de603INN5qv@early-bird.think.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!barmarReferences:
<1992Nov5.014143.15635@newshost.lanl.gov> <1992Nov5.051745.7369@linus.mitre.org> <1992Nov5.184831.16328@newshost.lanl.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.lang.misc Subject: Re: Pointers Date: 6 Nov 1992 16:20:19 GMT Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 33 Message-ID: <1de603INN5qv@early-bird.think.com> References: <1992Nov5.014143.15635@newshost.lanl.gov> <1992Nov5.051745.7369@linus.mitre.org> <1992Nov5.184831.16328@newshost.lanl.gov> NNTP-Posting-Host: telecaster.think.com