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: a07f3367d7,73cb216d191f0fef X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII X-Received: by 10.180.10.230 with SMTP id l6mr1352191wib.3.1365924757199; Sun, 14 Apr 2013 00:32:37 -0700 (PDT) Path: p18ni60968wiv.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!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!news.uni-weimar.de!medsec1.medien.uni-weimar.de!lucks From: Stefan.Lucks@uni-weimar.de Newsgroups: comp.lang.ada Subject: Re: Is this expected behavior or not Date: Tue, 9 Apr 2013 09:18:09 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <1gnmajx2fdjju.1bo28xwmzt1nr.dlg@40tude.net> <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> NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 X-Trace: tigger.scc.uni-weimar.de 1365491966 18678 141.54.178.228 (9 Apr 2013 07:19:26 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Tue, 9 Apr 2013 07:19:26 +0000 (UTC) X-X-Sender: lucks@debian In-Reply-To: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) Content-Type: TEXT/PLAIN; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Date: 2013-04-09T09:18:09+02:00 List-Id: 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 =3D 0 then Encoding :=3D CRTL.Unspecified; elsif Formstr (V1 .. V2) =3D "utf8" then Encoding :=3D CRTL.UTF8; elsif Formstr (V1 .. V2) =3D "8bits" then Encoding :=3D CRTL.ASCII_8bits; else raise Use_Error with "invalid Form"; end if; So the GNAT implementation of Ada.Text_IO can distinguish between=20 Unspecified, UTF8 and ASCII-8bits. This is more than I would have=20 expected. But it not really useful. Apart from the portability issue (what= =20 are the standard libs of other compilers doing?), there are a hell of=20 different encodings your filesystem might use. There is old CP437 from=20 MS-DOS time, there are more than ten different ISO 8859 encodings, ... A special technical issue is that the encoding of the fully qualified=20 filename can change even *within* the string itself -- the first part of=20 the path is using the encoding of the root filesystem, while the rest uses= =20 the encoding of the filesystem itself. In practice, this is mostly=20 harmless, since the first part typically looks like "/media/disk/" or=20 "/dev/sdb5", using only characters which are invariant under most common=20 encodings. But this still shows that the idea of letting Ada.Text_IO=20 dealing with the encoding will get you only so far. >> 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=20 define such a function, but the author of an Ada program cannot. There is= =20 no type with name Universal_Integer in Ada programs, and any attempt to=20 define one will, at best, overload the name of Universal_Integer, but=20 never give you the type that the standard denotes as Universal_Integer. >> 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=20 expect Integer'Pos(X) and Integer'Pos(Y) to be converted to the expected=20 result type even before the multiplication has been called. > 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=20 operation is performed. ------ I love the taste of Cryptanalysis in the morning! ------ --Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universit=E4t Weimar, Germany--