comp.lang.ada
 help / color / mirror / Atom feed
From: "David Thompson" <david.thompson1@worldnet.att.net>
Subject: Re: Out parameters in a function
Date: Wed, 24 Apr 2002 02:45:34 GMT
Date: 2002-04-24T02:45:34+00:00	[thread overview]
Message-ID: <i%ox8.42728$Rw2.3306926@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: pan.2002.04.16.22.51.21.649270.16266@jps-nospam.net

Eric G. Miller <egm2@jps-nospam.net> wrote :
> In <3CBCFCC8.6000206@worldnet.att.net>, Jim Rogers wrote:
>
> > Well, almost. C does not have a boolean type. C (since its first
>
> Umm, mostly true. C99 has stdbool.h, but it's still not really a
> builtin type of the language (int macros ...).
>
But stdbool.h bool is just sugar for _Bool, which _is_ builtin.
In C99.  But only for things you write; the builtin comparison
and logic (&& ||) operators (still) produce 0 or 1 of type int,
and all predicate contexts (if, while, etc.) expect and
isalpha() et al produce 0 or nonzero of type int.
(In C++ bool is builtin, and formally is used for predicates,
though there is still an implicit conversion from or to int.)

> And curiously, C can return structs containing arrays, but can't
> return arrays (as arrays are not "lvalues"). Boggle...

Actually arrays (or at least array variables) are lvalues, but in C
array types are not first-class:  inter alia you cannot assign one,
or pass it as an argument, or return it; instead (a primary expression
denoting) an array lvalue "decays" (converts) to a _pointer_ rvalue.
Which like all rvalues you cannot assign to, hence the diagnostic
(error) message you may have gotten.

You can assign/pass/return any struct, containing an array or not,
since before C89 though not at the very beginning.  And C99
cleans up a missed dark corner so you can standardly access
(the elements of) an array member of a struct rvalue e.g. function
return.  Implementations actually allocate such rvalues in the same
places as variables so this invariably worked in C89, it just wasn't
guaranteed by the standard.  (AFAICT it was in C++98.)

--
- David.Thompson 1 now at worldnet.att.net








  reply	other threads:[~2002-04-24  2:45 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-14 18:29 Out parameters in a function Nazgul
2002-04-14 19:45 ` David C. Hoos, Sr.
2002-04-15 10:49 ` John McCabe
2002-04-15 11:51   ` John McCabe
2002-04-15 13:43 ` Steve Doiel
2002-04-15 15:09 ` Ted Dennison
2002-04-16  8:49   ` John McCabe
2002-04-16 10:05     ` Dmitry A. Kazakov
2002-04-16 15:26       ` John McCabe
2002-04-16 19:34         ` Matthew Woodcraft
2002-04-16 20:10           ` Darren New
2002-04-17  1:30             ` Kent Paul Dolan
2002-04-17 16:15               ` Darren New
2002-04-19 17:39               ` Florian Weimer
2002-04-17 13:24             ` Stephen Leake
2002-04-17 16:32               ` Darren New
2002-04-17 21:03               ` Kent Paul Dolan
2002-04-18 12:14             ` Wolfgang Gellerich
2002-04-18 13:52               ` Dmitry A. Kazakov
2002-04-18 16:28                 ` Darren New
2002-04-17 10:17           ` John McCabe
2002-04-16 19:58         ` Kent Paul Dolan
2002-04-16 20:00         ` Kent Paul Dolan
2002-04-17  4:40           ` Jim Rogers
2002-04-17  5:27             ` Kent Paul Dolan
2002-04-17  5:50             ` Eric G. Miller
2002-04-24  2:45               ` David Thompson [this message]
2002-04-19 17:40             ` Florian Weimer
2002-04-19 18:26               ` Jim Rogers
2002-04-19 18:53                 ` Florian Weimer
2002-04-17  7:57           ` Dmitry A. Kazakov
2002-04-17 10:21             ` John McCabe
2002-04-24 17:21             ` Warren W. Gay VE3WWG
2002-04-26  7:32               ` Dmitry A. Kazakov
2002-04-15 16:24 ` Stephen Leake
2002-04-16 13:38   ` Ted Dennison
2002-04-17 11:55 ` Ingo Marks
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox