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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: GNAT.Serial_Communication and Streams Date: Tue, 24 Nov 2015 11:45:18 +0100 Organization: cbb software GmbH Message-ID: <1pl8set3ocirg.1v92rqtxaoq3z$.dlg@40tude.net> References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: uuaYi8S0HktMvp6/JW1g+A.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:28519 Date: 2015-11-24T11:45:18+01:00 List-Id: On Tue, 24 Nov 2015 10:28:20 +0000, Simon Wright wrote: > "Dmitry A. Kazakov" writes: > >> I don't see anything wrong with the original code. Stream attributes >> not to be trusted in general. An explicit conversion is clearer and >> cleaner, IMO. > > GNAT used to write strings to streams character-by-character, which is > seriously non-optimal (practically; if an exception occurs, who cares on > which character it happened?!) (Well, I/O errors cannot be recovered from anyway. So an exception in the middle is not that big problem) > But if you can't trust your compiler to write a string to a stream, what > can you trust it to do? Everything else. Stream attributes are not required to be portable or work in a certain way. That makes them no-no for all I/O, except memory and files never moved across the OS boundary. If an attribute should be used then always overridden with a trusted implementation. Of course there are shades of trust. Character'Write is expected to be fine almost anywhere. Integer'Write is expected to be patently wrong. > I wholly agree with "trust, but verify", though! You can verify given compiler for given machine. You cannot do that in general. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de