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: 103376,db88d0444fafe8eb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Surprise in array concatenation Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1125544603.561847.32140@g47g2000cwa.googlegroups.com> <14muavojz308w.1ouv7xin79rqu$.dlg@40tude.net> <4318486f$0$24154$9b4e6d93@newsread4.arcor-online.net> <43187a50$0$24162$9b4e6d93@newsread4.arcor-online.net> Date: Fri, 2 Sep 2005 21:48:13 +0200 Message-ID: <11p5i525v2q5d$.17ayuwvqhazo1.dlg@40tude.net> NNTP-Posting-Date: 02 Sep 2005 21:47:42 MEST NNTP-Posting-Host: 74e33cd6.newsread2.arcor-online.net X-Trace: DXC=jjke:XKD7iTYFAnNd=0_4TQ5U85hF6f;TjW\KbG]kaMXQ>n?D9BSA]\K=fR<:5ghhPWRXZ37ga[7ZAWU[gWam9fSWH2NB0R`_EX X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4411 Date: 2005-09-02T21:47:42+02:00 List-Id: On Fri, 02 Sep 2005 16:14:55 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: >> On Fri, 02 Sep 2005 12:42:06 +0200, Georg Bauhaus wrote: >> >>>Dmitry A. Kazakov wrote: >>> >>>>On 01 Sep 2005 12:04:17 -0400, Robert A Duff wrote: >>> >>>>>Heh? You want this: >>>>> >>>>> procedure Put(S: String) is >>>>> begin >>>>> for I in S'First..S'Last loop -- equivalent to S'Range >>>>> Put_Char(S(I)); >>>>> >>>>>to crash when S = ""? >>>> >>>>Yes. >>> >>>What is your approach to subranges then? >>> >>> function h(s: String) return Unsigned_32 is >>> prefix: String renames >>> s(s'first .. s'first + Integer'min(3, s'length - 1)); >>> result: Unsigned_32 := 0; >>> begin >>> for k in prefix'range loop >>> result := result or Shift_Left(Character'pos(prefix(k)), >>> (k - prefix'first) * 8); >>> end loop; >>> return result; >>> end h; >>> >>>(If you could assume for the moment that there is no >>>Unchecked_Conversion and not a different/better algorithm etc.) >> >> I don't see any problem, so far. Subrange of an empty range is empty. > > But earlier you said that s'first .. ... should crash when > s = "". Yes, because the code above is incorrect in my view. You should explicitly test for s'length = 0. >> As >> for the checksum of an empty string it is to be extra defined. >> >> You cannot in general case reverse any possible sequence S1, S2, S3, ... to >> deduce S0. > > This requirement being generated by arbitrarily applying > the mathematical habit of starting things, deducing thing, > extending things to become some general case (not well defined > for real computers), etc. Empty range is such a generalization! > Basic mathematical facts > are basic relative to some starting point from which you perform > mathematical reasoning. What about secondary school as a starting point? (:-)) >> IF the sequence is a series bound by some operation *: >> SN = x1 * x2 * ...* xN >> >> AND * is a group operation >> >> THEN you can take the unit element of the group for S0. > > And what does mathematical group theory offer when the computer > executes fine without it? Why don't you start your basic > mathematical theory from things that work, and explain them > first? It perfectly predicts where things like above work and where they fail. Just try to rewrite your program to make it working for any array type. Note there is nothing particularly difficult in writing some program in C++. But *programming* in C++ is an immense problem. See any parallel? > If a sphere of negative radius opens many interesting insights > into unforeseen extensions of geometry, will this have an > influence on a pot maker's occupation? What about zero radius? If you want to play a Luddite, then start with prohibiting empty strings. Do a writer need empty texts? > I'm not asking these questions because I believe that mathematics > is the wrong science for approaching real computers. It's not. > > However, every once in a while I'm having to defend > that running computers and performing mathematics are two > sets of operations. They have a fair amount of overlap. [..] What is the point? Do computers something which cannot be described using mathematics? That is not what you are saying. Then what? A trivial analysis shows inconsistency of A'First..A'First-1. There is nothing new in that. It is well known. A pragmatic school calmly admits it, but points out that to fix would probably mean too much work, and that it's much too late anyway, especially, because programs are infested with constructs like A'First..A'Last, Index..A'Last etc. But you seem to be seeking for rather philosophic arguments to keep it inconsistent. (:-)) >> Now, take something else: let * be max, what would be the maximum of an >> empty array? > > A problem of math-think. Like this > > ... talking to son: > > "See this little wood over there? I have counted the trees, > there are 139." > > ... a little later: > > "Remember I told you about this wood having 139 trees, 14 > years ago? Now there are only 23 left." > > ... talking to granddaughter visiting: > > "See this little wood over there?" -- "No." > -- "It has 0 trees". -- "Ha, ha." > > If there is nothing about which to say anything, > then mathematicians decide to say something about > it: truth. Useful, but in a material setting, you have > to consider whether it makes sense. Absolutely. Mathematics is applied to solve problems. To be able to do it the mathematical models you use have to be adequate. But even before that they have to be *consistent*. For good or bad, but no inconsistent thing can be adequate. > Using your Max example, > I could ask those mathematicians about the maximum of a > subset of the natural numbers (possibly empty!). I'd venture > a guess that the answer will likely be, "It depends.". > > For example, you have given "extra defined". ;-) Exactly as with A'First. It depends! You choose A'First to exist for any array. But I prefer a more usable in my view: A(A'First) does exit or Index'Pos(A'First) <= Index'Pos(A'Last) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de