From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11232c,bde6489d2ec79329 X-Google-Attributes: gid11232c,public X-Google-Thread: 103376,9245b8db9abd376c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-23 19:45:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!wn3feed!wn1feed!worldnet.att.net!135.173.83.55!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada,misc.misc References: <4519e058.0204150709.55c94dfb@posting.google.com> <3cbbe583.3628858@news.demon.co.uk> <3cbc3f05.26543327@news.demon.co.uk> <3CBCFCC8.6000206@worldnet.att.net> Subject: Re: Out parameters in a function X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Wed, 24 Apr 2002 02:45:34 GMT NNTP-Posting-Host: 12.89.146.146 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1019616334 12.89.146.146 (Wed, 24 Apr 2002 02:45:34 GMT) NNTP-Posting-Date: Wed, 24 Apr 2002 02:45:34 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:23030 misc.misc:6841 Date: 2002-04-24T02:45:34+00:00 List-Id: Eric G. Miller 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