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.92.202 with SMTP id co10mr3641956wib.1.1366082136397; Mon, 15 Apr 2013 20:15:36 -0700 (PDT) Path: p18ni69727wiv.0!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.teledata-fn.de!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.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 17:20:35 +0200 Organization: Bauhaus-Universitaet Weimar 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> NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 X-Trace: tigger.scc.uni-weimar.de 1365520912 1793 141.54.178.228 (9 Apr 2013 15:21:52 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Tue, 9 Apr 2013 15:21:52 +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 Content-ID: Date: 2013-04-09T17:20:35+02:00 List-Id: On Tue, 9 Apr 2013, Dmitry A. Kazakov wrote: > This is why string types SHALL be designed properly in order to handle th= is > without introducing millions of I/O packages. We are in violent agreement here. The question is how much compatibility=20 is needed between a new string type and the gazillions of old and broken=20 ones, not that strings SHOULD be designed properly ... > 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. It was you who came up with the example of Ada.Text_IO.Open, not me. > You cannot do > > X : String; > > either. String is a pseudo-type? This is a straw man argument. String is not pseudo. As you know very well, you can do X: String :=3D ... or X: String(A ..B),= =20 while you can't do anything similar for Universal_Integer. >> 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= =2E OK, so look at the semantic. Different semantic means the same operation=20 with the same inputs behave differently. The following program fragment nicely prints "Smaller or Equal": if ((Character'Pos('z') ** Character'Pos('z')) > (Character'Pos('z') ** Character'Pos('z'))) then Put_Line("Larger"); else Put_Line("Smaller or Equal"); end if; This is really cool -- the sematic of Universal_Integer enables us to=20 perform operations over huge integers without overflows. Now, guess what the following program fragment does? S: String :=3D "zzzz"; begin if ((Character'Pos(S(1)) ** Character'Pos(S(3))) > (Character'Pos(S(2)) ** Character'Pos(S(4)))) then Put_Line("More"); else Put_Line("Less or Equal"); end if; The output is neither "More" nor "Less or Equal" but "raised CONSTRAINT_ERROR : arit64.c:52 overflow check failed". (When using gnat, don't forget "-gnato" to switch on overflow checks.) Whenever the compiler cannot statically evaluate expressions of type=20 Universal_Integer it switches to run time arithmetic over some integer=20 type available at run time. This means, the expression behaves according=20 to that type's semantic, raising Constraint_Error on overflows included. If you insist that all the operations (such as the "**") above are over=20 Universal_Integer, than that would mean the semantic of Universal_Integer is allowed to change, depending on compile. versus run time. That would be even more "pseudo". ;-) ------ I love the taste of Cryptanalysis in the morning! ------ --Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universit=E4t Weimar, Germany--