Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: is there a way to ask a variable what it is?
Date: Tue, 18 Feb 2020 08:56:09 -0800
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <86lfozeswm.fsf@linuxsc.com>
References: <87zhe5pzqf.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="d9b0a35ddf05bf8591aa2d3738ff843a"; logging-data="26541"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SEvqmWV3cHmprzJ8qn/q8+3brZtY8qew="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:kyjmH2zZXhrKfU7qmiygT6XWF/A= sha1:Utzg+qYig2m+3XxUbSCTpglmKmk=
Xref: csiph.com comp.lang.c:150074
Ben Bacarisse writes:
> [...] C is a statically typed language so all type information,
> and everything easily derived from type information, is known at
> compile time.
I don't think that's right exactly. For one example, some type
information may be known in one translation unit but not known
in another. A declaration like
extern int special_values[];
offers partial but not complete type information in this TU, and so
is not known at compile time. A second example is variable length
arrays. Here the type information is not known until run time, and
usually is not fixed but varies with different invocations. A third
example pertains to structures and unions in dynamically allocated
memory, where code inspects a tag using the "one special guarantee"
for structure member access, to select a specific struct type (using
a cast) at run time. Certainly there are other examples but I think
these provide enough variety and flavor to motivate the objection.