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 X-Google-Thread: a07f3367d7,73cb216d191f0fef X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.92.202 with SMTP id co10mr1363064wib.1.1365924787618; Sun, 14 Apr 2013 00:33:07 -0700 (PDT) Path: p18ni60971wiv.0!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!94.232.116.11.MISMATCH!feed.xsnews.nl!border-1.ams.xsnews.nl!plix.pl!newsfeed2.plix.pl!217.153.128.51.MISMATCH!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Is this expected behavior or not Date: Tue, 9 Apr 2013 10:17:17 +0200 Organization: cbb software GmbH Message-ID: References: <3gv2jwc95otm.pl2aahsh9ox8.dlg@40tude.net> <1gkxiwepaxvtt$.u3ly33rbwthf.dlg@40tude.net> <1fmcdkj58brky.bjedt0pr39cd$.dlg@40tude.net> <1bj564vat3q1j$.1s4d00rlzx4ux$.dlg@40tude.net> <4hzv51v872q2$.1imijbwd7heqm$.dlg@40tude.net> <1htu9idmcci7x.1vr9eafeivqah$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2013-04-09T10:17:17+02:00 List-Id: On Tue, 9 Apr 2013 09:18:09 +0200, Stefan.Lucks@uni-weimar.de wrote: > On Mon, 8 Apr 2013, Dmitry A. Kazakov wrote: > >>> Ada.Text_IO would have to know the encoding, but it doesn't. >> >> See s-fileio.adb, lines 845-857. > > Cool! I haven't been aware of that. Starting with line 483: > > if V1 = 0 then > Encoding := CRTL.Unspecified; > > elsif Formstr (V1 .. V2) = "utf8" then > Encoding := CRTL.UTF8; > > elsif Formstr (V1 .. V2) = "8bits" then > Encoding := CRTL.ASCII_8bits; > > else > raise Use_Error with "invalid Form"; > end if; > > So the GNAT implementation of Ada.Text_IO can distinguish between > Unspecified, UTF8 and ASCII-8bits. This is more than I would have > expected. But it not really useful. Of course it is useful because text files have different encoding. > Apart from the portability issue (what > are the standard libs of other compilers doing?), there are a hell of > different encodings your filesystem might use. There is old CP437 from > MS-DOS time, there are more than ten different ISO 8859 encodings, ... This is why string types SHALL be designed properly in order to handle this without introducing millions of I/O packages. > A special technical issue is that the encoding of the fully qualified > filename can change even *within* the string itself -- the first part of > the path is using the encoding of the root filesystem, while the rest uses > the encoding of the filesystem itself. File name is not a string in first place. Ada.Directory and other I/O packages are broken in that respect, but that is irrelevant here. >>> compile time. >> >> This is wrong. See 3.5.5(2) as an example of a non-static function >> returning Universal_Integer. > > Well, the authors of the standard can use "standard definition magic" to > define such a function, but the author of an Ada program cannot. You cannot do X : String; either. String is a pseudo-type? Is it RM terminology? (:-)) Now consider Ada.Strings.Unbounded. It has a whole lot of mixed string type operation declared: Append, "&", "=", "<", ">", ">=", "<=". Now as we learned that String is "pseudo-type," it would be OK to mix. Right? But then, what is the buzz? If string types are pseudo-type we can mix them happily anyway! (:-)) >>> You just used the already existing object 2 of type constant >>> Universal_Integer. >> >> Integer'Pos (X) * Integer'Pos (Y) > > Language lawyers may correct me, but if X and Y are not static, I would > expect Integer'Pos(X) and Integer'Pos(Y) to be converted to the expected > result type even before the multiplication has been called. Character'Val (Integer'Pos (X) * Long_Integer'Pos (Y)) >> Universal_Integer and other numeric types can be mixed in arithmetic and >> other operations. Period. > > Again, my understanding is that they are converted before any run-time > operation is performed. Wrong but irrelevant as well, because semantically there is no difference. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de