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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ff5003422436e4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-21 11:36:34 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!spool.mu.edu!bloom-beacon.mit.edu!ai-lab!life.ai.mit.edu!tmb From: tmb@arolla.idiap.ch (Thomas M. Breuel) Newsgroups: comp.lang.ada Subject: Re: Easily-Read C++? Date: 21 Oct 1994 14:38:25 GMT Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle Perceptive) Message-ID: References: <3719k1$11gt@watnews1.watson.ibm.com> <85C92963672@annwfn.com> Reply-To: tmb@idiap.ch NNTP-Posting-Host: arolla.idiap.ch In-reply-to: a311581@ventures.NoSubdomain.NoDomain's message of Fri, 14 Oct 1994 21:13:06 GMT Date: 1994-10-21T14:38:25+00:00 List-Id: In article a311581@ventures.NoSubdomain.NoDomain (Kevin Cline) writes: |In article , emery@goldfinger.mitre.org (David Emery) writes: ||> The ambiguity 'inherent' in declarations such as ||> char * foo; ||> char ** foo; ||> char foo[]; ||> char *foo[]; ||> causes problems for C tools. Even though each of the above is ||> 'unambiguous', common usage means that any of these can be used to ||> represent the others. At least one tool I know of (an RPC generator ||> for C) requires the user to disambiguate some of the above ||> declarations, to make sure that the tool generates the right code. ||> |These declarations are not equivalent. The first is equivalent to the third, |and the second to the fourth. | |The equivalence of C pointers and arrays is unfortunate. It is maintained |by C++ for backward compatibility reasons. Most C++ applications use |a library template array class instead of C arrays. None of those declarations are equivalent (if people want to criticize C, they should at least have a basic understanding of it!). Furthermore, the problem that RPC systems have with C is that arrays and pointers do not carry bounds information with them. (Another problem is that C pointers can point to heap data, into the middle of other data structures, or to stack data.) That is indeed a problem in some situations, but it is not related to declaration syntax. On the other hand, real-world users will probably not accept a language that doesn't provide some equivalent of C's plain arrays: the overhead of carrying bounds information around at runtime is sometimes unacceptable. In C++, none of this is a problem: arrays usually carry bounds information (static or dynamic) and can easily be serialized for RPC. C-style arrays need only be used in very specific situations. Thomas.