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-Thread: 103376,a9b0810d3106d9b8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 20 Apr 2011 23:09:16 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Fun with C References: <27cf3992-4132-4483-9110-adc7a089cd4a@e8g2000vbz.googlegroups.com> <3ccf18a2-ba10-42bc-aeab-9368749961fb@a11g2000pro.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4daf4b7d$0$6878$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 20 Apr 2011 23:09:17 CEST NNTP-Posting-Host: 8038dcd2.newsspool2.arcor-online.net X-Trace: DXC=7990BZYW_ALgj[ZPFj7ehOA9EHlD;3YcB4Fo<]lROoRA8kFejVHgUbC0Le8kSMB9^[]=IQQMO X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:19902 Date: 2011-04-20T23:09:17+02:00 List-Id: On 4/20/11 9:04 PM, Vinzent Hoefler wrote: > : > > |Some of the facets of the spirit of C can be summarized in phrases like > |(a) Trust the programmer. > |(b) Don't prevent the programmer from doing what needs to be done. > |(c) Keep the language small and simple. > |(d) Provide only one way to do an operation. > |(e) Make it fast, even if it is not guaranteed to be portable. Not much different from what is true about Ada. (a) (Like Haskell,) Ada trusts the programmer to be explicit, e.g. instantiating Unchecked_Conversion. Normally, though, Ada doesn't trust us when we want to pass addresses of local objects up the call chain. But it is possible. (b) Ada seems to make it a little difficult to get pointer arithmetic from Interfaces.C.Pointers to omit null tests. But otherwise... (c) The C standard is about the same size as Ada's, isn't it? C is simple? (d) Are there two ways to do an operation in Ada? (e) Some Ada programs are fast and still guaranteed to be portable. That's true of some C programs as well. Ada programs might need unchecked conversions and representation clauses to make a program non-portable. Although, an Ada program need not be non-portable even though we let the *compiler* choose efficient the representation on a target machine: type Roman is ('M', 'D', 'C', 'L', 'V', 'I', 'X'); for Roman'Size use Integer'Size; function To_Integer is new Unchecked_Conversion(Roman, Integer); Now To_Integer(X) + N; will produce the "byte operation [that] is more efficient on the target machine" iff the compiler uses efficient byte operations for Integer. Or this, type S is new String; for S'Component_Size use Integer'Size; So I guess C's (e) is working around the fact that C's choices would not allow the programmer to say what needs to be done?