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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c75fd3043cfdcb58 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Received: by 10.66.82.195 with SMTP id k3mr1346008pay.23.1344323818630; Tue, 07 Aug 2012 00:16:58 -0700 (PDT) Path: g9ni3089241pbo.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!ctu-peer!news.nctu.edu.tw!goblin1!goblin.stu.neva.ru!feeds.phibee-telecom.net!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!reader03.nrc01.news.zen.net.uk.POSTED!not-for-mail Date: Mon, 30 Jul 2012 23:12:28 +0100 From: Mark Murray User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Formatted IO - Fortran style or similar. References: <50164ad8$0$1156$5b6aafb4@news.zen.co.uk> In-Reply-To: Message-ID: <501706ca$0$1151$5b6aafb4@news.zen.co.uk> Organization: Zen Internet NNTP-Posting-Host: 6822bd6d.news.zen.co.uk X-Trace: DXC=^[0GOm9djjZd]c;>LNFRcSf2FgniPJjgR=dR0\ckLKGPWeZ<[7LZNRV83LEA4?@k On 30/07/2012 10:59, Ian Clifton wrote: > I’m not quite sure what facilities you’re after—I don’t know C’s > printf()/scanf(), but presumably they are quite different from Fortran’s > format control—but I suspect the answer is going to be “Ada’s approach > is different” (see below). The syntax isn't all that important; its the fine-grained method of specifying output with a format + list_of_variables. Fortran separates the format from the read/write statements containing the list of variables, C's printf/scanf put the format string as the first argument of the function call. With both, quite detailed I/O lines can be specified with a reduction in function calling. I like them because of the compactness: printf("A=%d B=%6.3f C=0x%04X\n" A, B, C); ... rather than multiple calls. >> I could have sworn I saw a PL/1-style "picture" version of this, but I'm >> coming round to believing that this was "customer code", not standard >> library. > > Here, you could be thinking about “Edited Output for Decimal types”, > described in the ARM Appendix F. Could be, thanks! >> PS: Is it really the case that put(some_integer,16) will _always_ >> print the '16#9999#' format, and that there is on way _in_the_ >> _standard_library_ of *not* getting the '16#.....#' wrapper? >> Yes, I know there are ways you can get rid of it (eg with a slice), or >> by "rolling your own" - alternatives aren't my question here :-). > > I believe Ada’s approach is to specify the results of > put(some_integer,16) sufficiently carefully that you can do such > post‐processing with the provided string manipulation packages and be > confident of the final result. In other words, what you are trying to > avoid ARE the language’s facilities for doing this sort of thing. I ought > to mention in passing, the Ada.Text_IO packages are a little > controversial, many dislike them, but I believe they are under‐rated. If that is the "Ada way", then so be it. :-) I held back on that method as it felt "wasteful"; why generate something if you know you don't need it? ("I want XXXX (hexadecimal), why do I need to generate 16#XXXX# first?") I suppose that learning a language's idioms are part of learning the language. Thanks for the help! M -- Mark "No Nickname" Murray Notable nebbish, extreme generalist.