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!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Text_IO, was: Re: Something I don't understand Date: Tue, 18 Feb 2014 09:28:14 +0100 Organization: cbb software GmbH Message-ID: <8c7vp2nw3983$.1x28l8u1eo1ko$.dlg@40tude.net> References: <4a3e55f6-9f54-4084-9f37-96efd4b0d349@googlegroups.com> <0b358700-871b-4603-addd-65e07c7d59e5@googlegroups.com> <530310c2$0$9515$9b4e6d93@newsspool1.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: I5Na6+WsEzT8WoegI0VZTA.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:18657 Date: 2014-02-18T09:28:14+01:00 List-Id: On Tue, 18 Feb 2014 08:50:27 +0100, Georg Bauhaus wrote: > On 17/02/14 21:09, Dmitry A. Kazakov wrote: >> Actually it is possible to have it statically type safe with some little >> compiler support. > > What does "little compiler support" mean? Binding (and checking) terms of the format expression against the types of values: Put ( "Index=" & I (Field=>8, Align=>Right) & "X=" & F (10.2), (Index, X) ); Here I, integer format, must match Index, F, real format must match X. >> Ada's style of independent Put and Get is so much better. >> Note that even C++ switched to this style, I mean its out<< and in>> >> operators. > > C++, however, has automatic template resolution, Ada hasn't. > Nor does Ada have anything more fancy than ordinary types, > no type parameters of types directly, etc. You would need ad-hoc tuples for handling lists of assorted values to print, as I used in the example above. Or else you can use aspects which are so messy anyway that whatever harm to Ada's syntax it would do, it is already done: Put (File) with Format => ..., Value1 => ..., ... ValueN => ...; >The Spitbol operators > all return Pattern, and they do so for operands of type Pattern, > character stuff, or function pointers only. No MD. Yes. I prefer a MD solution and no formats at all. > So, I guess we cannot even have C++-like operator<< etc, > without a "little compiler support"? But << operators is an MD solution! I was talking about a formats. Formats is a poor-man's dispatch. Instead of using the type information from the value, the format specifies the type explicitly, e.g. %d, reads among other "integer". That introduces nothing but yet another source of errors. Also when pursued honestly as FORTRAN and PL did it requires a whole mess of means for formatting arrays (remember that horror?) and for a modern OO language records, record extensions etc. Good luck with that. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de