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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.43.88.73 with SMTP id az9mr9014432icc.5.1396280344655; Mon, 31 Mar 2014 08:39:04 -0700 (PDT) X-Received: by 10.182.109.36 with SMTP id hp4mr480178obb.30.1396280344531; Mon, 31 Mar 2014 08:39:04 -0700 (PDT) Path: border1.nntp.dca.giganews.com!nntp.giganews.com!ur14no1164641igb.0!news-out.google.com!gi6ni59igc.0!nntp.google.com!ur14no1164618igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 31 Mar 2014 08:39:03 -0700 (PDT) In-Reply-To: <1656778100417879549.835031laguest-archeia.com@nntp.aioe.org> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <7f1c01c5-3563-4b94-9831-152dbbf2ecdc@googlegroups.com> <1656778100417879549.835031laguest-archeia.com@nntp.aioe.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Your wish list for Ada 202X From: Adam Beneschan Injection-Date: Mon, 31 Mar 2014 15:39:04 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:185432 Date: 2014-03-31T08:39:03-07:00 List-Id: On Sunday, March 30, 2014 6:40:24 AM UTC-7, Luke A. Guest wrote: >=20 > > One wish to ease Input/output : >=20 > > To have some equivalent of C primitive : printf("%c %c %c %c %c \n %c %= c %c %c %c \n", >=20 > God no. This requires parsing the string in every call, the Ada does it n= o > is superior.=20 I can't tell what you're trying to say here--it's not grammatical. If you'= re trying to say something along the lines of "the Ada way to write this", = I'm not sure just what that is. I'm sure there are several opinions about = what "the Ada way" is for this. > Plus it requires parameter passing from the right rather than > the left. No, it wouldn't require parameter passing like that at all. Some different= mechanism would no doubt have to be invented, though. The original C didn't have function prototypes at all. Most of the time, y= ou simply used the function, and the compiler would assume it existed. If = the return type were something other than "int", you might have to write an= "extern" declaration to tell the compiler the function existed and its ret= urn type, but you still didn't tell it anything about the parameters. The = compiler assumed you knew the parameter types and got them right, and if yo= u didn't, then you got to have fun debugging your error. But functions wit= h variable numbers of argument like printf() could be made to work because = the compiler would push the arguments on the stack right-to-left, and the p= rintf() function would read them from the stack like that. But, certainly, if one were to design a mechanism to allow such parameter p= assing, one wouldn't be constrained to use the same mechanism adopted by an= extremely low-level 1960s programming language like C. There are many oth= er possibilities, such as pushing the number of parameters and the number o= f bytes in each passed value as hidden parameters on the stack. The assump= tion here would be that the printf function would be *declared* to take a v= ariable-argument-list, and therefore the compiler would know, on *both* sid= es (when compiling the subprogram body, and when compiling the call), that = the special mechanism for passing variable-argument lists would need to be = in effect. This assumption was *not* true for the original C, which is why= the right-to-left thing was necessary. In Java, for instance, methods with variable-length argument lists are just= treated as arrays. So when you say System.out.printf("Count=3D%d value=3D%8.2f\n", someInteger, someFloat)= ; printf will see two parameters: a String, and an array of two Objects, wher= e the first element is an Integer and the second is a Float. (All "objects= " in Java are descended from Object, and non-objects like "int" will be aut= omatically converted to Integer objects in some contexts.) printf can then= just traverse the array; it can also check to make sure the variable argum= ent list has the correct number of parameters and parameter types. =20 I'm not saying that Ada needs a feature like this, or that it should be imp= lemented the way Java did it. I'm just saying that it clearly is *not* nec= essary to use right-to-left parameter passing in order to add a feature lik= e this to the language. =20 -- Adam