Article View: comp.std.c
Article #4068Re: Function-prototype scope: Why?
From: Stan Ryckman
Date: Thu, 21 Sep 1995 04:07
Date: Thu, 21 Sep 1995 04:07
48 lines
2376 bytes
2376 bytes
In article <43qjdk$loj@caip.rutgers.edu>, <halasz@caip.rutgers.edu> wrote:
>In article <43pdgk$b3i@rdsunx.crd.ge.com>, volpe@bart.crd.ge.com (Christopher R. Volpe) writes
>> ....
>> You have yet to give an example of why things would be bad if there were no
>> such thing as function prototype scope (other than the parameter namespace
>> collision problem I already pointed out).
>I hav, but you ignord it. Consider the PDP-11: pointer to 'char' and
>pointer to 'int' need different-"shaped" pointers.
char* and int* may indeed be different "shapes"; in fact, sizeof them
may differ. (Well, I think so, but let's just say I'm 95% sure about
the sizeof thing.)
>For generating
>right argument-passing code for it, the compiler needs to know which it
>is. A 'struct' with one field a compiler is free in code to treat as
>if it were onlie that which it contains.
It is only free to do so if other conditions are true:
All pointers-to-struct must have the same "shape"; I know Chris knows
this, but I think he's missing the fact that you don't realize this.
Given:
struct cs { char c }; struct cs* csp;
struct is { int i }; struct is* isp;
char* cp;
int *ip;
Then:
csp and isp must have the same shape. It may be the same
shape as (a) cp or (b) ip or (c) both or (d) neither; however,
if cp and ip have different shapes, then it is definitely false
to claim that both (A) cp and csp can have the same shape and
(B) ip and isp can have the same shape.
Hence, pointers to incomplete structure types can be handled by
routines which "know" nothing about the particulars of the structures
involved, other than that they are structures.
I hope that clarifies things somewhat, though I'm afraid I've
explained my kibbitzer's view of this disagreement rather poorly.
Cheers,
Stan.
--
HELP! I'M BEING HELD PRISONER IN A .SIGNATURE FACTORY!
Stan Ryckman sgr@alden.com
Technical Details
Message-ID:
<43qod5$clf@ae-sun01.alden.com>Path:
arc1-ca.pugleaf.net!alden.com!not-for-mailReferences:
<43cgmb$cec@news0.rain.rg.net> <43er80$458@caip.rutgers.edu> <43pdgk$b3i@rdsunx.crd.ge.com> <43qjdk$loj@caip.rutgers.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!alden.com!not-for-mail From: sgr@ae-sun01.alden.com (Stan Ryckman) Newsgroups: comp.std.c Subject: Re: Function-prototype scope: Why? Date: 21 Sep 1995 00:07:01 -0400 Organization: Amber & Sneakers Fan Club Message-ID: <43qod5$clf@ae-sun01.alden.com> References: <43cgmb$cec@news0.rain.rg.net> <43er80$458@caip.rutgers.edu> <43pdgk$b3i@rdsunx.crd.ge.com> <43qjdk$loj@caip.rutgers.edu> NNTP-Posting-Host: ae-sun01.alden.com