|
From: Georg Bauhaus on 3 Sep 2005 16:01 Dmitry A. Kazakov wrote: > Just try to rewrite your program to make it working for any array type. A rewrite for any array (I presume: any index) will fail only where mathematically subtracting 4 from 3 will fail in N. > C++. But *programming* in C++ is an immense problem. See any parallel? Are you saying that C++ is less mathematical than Ada? > What about zero radius? If you want to play a Luddite, then start with > prohibiting empty strings. Do a writer need empty texts? Writers have used empty texts. Programmers frequently use empty strings, for I/O. > Do computers something which cannot be described using > mathematics? Yes, most real computers, if not all of them, cannot at all be shown to be a Turing machine equivalent. We do not even know whether or not the world's most often sold CPU works properly, at least not in a mathematically satisfying sense ("yes" or "no"). Now think of the peripherals, etc. A real computer is a statistically reliable device, but you cannot mathematically show that your desktop computer does what we believe it does. > That is not what you are saying. Then what? Another problem with computer mathematics is that it largely neglects continuous time, and bare I/O operations. Time is transformed into ticks, I/O is reduced to 'Valid plus compiler magic built on top of OS routines which mostly work - for whatever reason. Who can show, in mathematically sufficient detail, the way of some bits generated by a partition running on computer A sent to a partition running on computer B? (Who *wants* to do this? :) This requires statistics, rules of thumb, and experiments. > A trivial analysis shows inconsistency of A'First..A'First-1. The inconsistency of A'First..A'First - 1, if any, is relative to a set of definitions. It seem that off-bounds indices are a ubiquituous feature, found in several programming languages' algorithms and data structures. The indices avoid, for one thing, a proliferation of conditionals like if x'length = 0 then ... else perform(...) end if; Without the special test, you can unconditionally say forall things in x | P ... or as-soon-as cursor is off things in x | P ... Something that I think is frequently found in math literature ;-)
From: Dmitry A. Kazakov on 4 Sep 2005 06:13 On Sat, 03 Sep 2005 22:01:03 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov wrote: > >> C++. But *programming* in C++ is an immense problem. See any parallel? > > Are you saying that C++ is less mathematical than Ada? I'm saying that the source of C++'s problems is a less consistent, careless, sometimes mindless design than Ada has. >> What about zero radius? If you want to play a Luddite, then start with >> prohibiting empty strings. Do a writer need empty texts? > > Writers have used empty texts. Does Amazon sell any empty books? > Programmers frequently use empty strings, for I/O. Then show me the "first character" printed! (:-)) >> Do computers something which cannot be described using >> mathematics? > > Yes, most real computers, if not all of them, cannot at all be shown to > be a Turing machine equivalent. Firstly, they can. You probably meant computer systems as whole (+inputs/outputs.) It is not what usually called "computer".) Secondly, mathematics does not end in Turing machines. > We do not even know whether or not the > world's most often sold CPU works properly, at least not in a > mathematically satisfying sense ("yes" or "no"). It is a silly argument. Next time paying a fine, tell the officer that because you cannot tell if traffic lights work properly, you can ignore traffic regulations. > Now think of the peripherals, etc. See above. > A real computer is a statistically > reliable device, but you cannot mathematically show that your desktop > computer does what we believe it does. The probability theory is at your service. But wait, should I understand the above as: Empty'First..Empty'First-1 is correct, because Empty might be random? Come on! (:-)) >> That is not what you are saying. Then what? > > Another problem with computer mathematics is that it largely neglects > continuous time, and bare I/O operations. You should address that to CS which is only a stepdaughter of mathematics. Then the problem is not in which part of mathematics one would apply. The problem is that you seem to reject mathematics (and logic) as a tool, proposing nothing instead. The language should be consistent, there is no doubt about it. > Time is transformed into > ticks, I/O is reduced to 'Valid plus compiler magic built on top of > OS routines which mostly work - for whatever reason. > Who can show, in mathematically sufficient detail, the way of > some bits generated by a partition running on computer A sent > to a partition running on computer B? (Who *wants* to do this? :) Huh, who can solve Maxwell's equations for a TV set? Does it mean that you can create one ignoring laws of physics? > This requires statistics, rules of thumb, and experiments. I.e. random empty strings... >> A trivial analysis shows inconsistency of A'First..A'First-1. > > The inconsistency of A'First..A'First - 1, if any, is relative > to a set of definitions. Yep, like: 1. "any unconstrained array type shall have empty instances" 2. "any array instance contain its lower and upper bound" > It seem that off-bounds indices are a ubiquituous feature, found in > several programming languages' algorithms and data structures. Re-read what you wrote: an off-bound [array] index is an array bound! Is it "off" or not? (:-)) > The indices avoid, for one thing, a proliferation of conditionals like > if x'length = 0 then ... else perform(...) end if; > Without the special test, you can unconditionally say > > forall things in x | P ... Absolutely! And Ada has this construct: for I in P'Range loop x := P (I); ... -- do something with x It would be nice if Ada would support abstract iterations like: for x in P loop ... -- do something with x Better ADT is what Ada needs. > or > > as-soon-as cursor is off things in x | P ... No! This is an extremely bad idea borrowed for C pointer arithmetic. It presumes that cursor might be off. It is a very strong assumption, which may have a great impact on the algorithm: 1. The cursor have to have "off" values. Consider the type Character, you'll need to extend it with two values, left and right. Presently Ada does not support this. And if it did, then it would require another representation for extended Character with conversions forth and back all the way. An alternative? Well, remember C's nul-terminated strings? Do you enjoy them? 2. There should be a way to construct off-values. That might be very non-trivial. Example: pointers. Try to find a pointer that does not point to some object. You have to undertake some actions to ease it. For example to reserve null with the *distributed* overhead of testing for "null" throughout the program. 3. As I said before, you have a distributed overhead of distinguishing two sorts of cursors. That would make optimization difficult. It is a halting problem to determine if a cursor is off. > Something that I think is frequently found in math literature ;-) I'm not a mathematician, so I cannot tell. But I think that the set theory explicitly forbids unbound quantifiers, which would otherwise refer to the set of "all things" (an equivalent of "off-set" thing.) It is no-no. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
From: Jean-Pierre Rosen on 5 Sep 2005 04:34 Jacob Sparre Andersen a ýcrit : >>The values are integral multiples of small, which can be supplied by >>the user. So I'd expect to be able to use fixed point types as >>array indices etc. You cant :( Wouldn't fixed point be *much* more >>useful if it was discrete? > That's the view of the solution space. The view of the problem space is that they are a different approximation of real numbers (floating point values being the other one). And you can't index an array with real values, whether float or fixed. -- --------------------------------------------------------- J-P. Rosen (rosen(a)adalog.fr) Visit Adalog's web site at http://www.adalog.fr
From: Jean-Pierre Rosen on 5 Sep 2005 04:38 Robert A Duff a ýcrit : > Why would you want an unconstrained array indexed by enumeration type? > And why would you want an empty array if the array type is constrained? > I do that all the time, especially in ASIS programming. You may have arrays indexed with subranges of declaration_kinds for example. -- --------------------------------------------------------- J-P. Rosen (rosen(a)adalog.fr) Visit Adalog's web site at http://www.adalog.fr
From: Dr. Adrian Wrigley on 5 Sep 2005 07:29
On Mon, 05 Sep 2005 10:34:01 +0200, Jean-Pierre Rosen wrote: > Jacob Sparre Andersen a ýcrit : > >>>The values are integral multiples of small, which can be supplied by >>>the user. So I'd expect to be able to use fixed point types as >>>array indices etc. You cant :( Wouldn't fixed point be *much* more >>>useful if it was discrete? >> > That's the view of the solution space. The view of the problem space is > that they are a different approximation of real numbers (floating point > values being the other one). And you can't index an array with real > values, whether float or fixed. Yes it is a solution space view. The point that I was making was that there were straightforward implementations available to compilers. The view of the problem space is that an array indexed by a real value represents an arbitrary univariate function. I use these "all the time" in generating probability density estimates. And also for lookup of complicated functions. The example of computing histograms from Jacob is closely related. So I'm slightly surprised to hear you say you can't index an array with real value (approximations). -- Adrian |