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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fa2cc518ef3b992c X-Google-Attributes: gid103376,public From: "Samuel T. Harris" Subject: Re: scripting/extension language for Ada (we have an opportunity here) Date: 2000/02/16 Message-ID: <38AAF0C1.C3F82C40@Raytheon.com>#1/1 X-Deja-AN: 586621635 Content-Transfer-Encoding: 7bit References: <389207CC.C16D80E8@averstar.com> <38971028.BB16D8A2@earthlink.net> <3899F757.FAE131B3@free.fr> <389D43A6.786C7B79@free.fr> <880gpk$fv04@ftp.kvaerner.com> <38A47E5A42406034@earthlink.net> <38A53714.3EBC10C3@online.no> <38A5E4FC.9C20A0E4@Raytheon.com> <38A9A7D4.5331F2C3@Raytheon.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Raytheon Aerospace Engineering Services Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-02-16T00:00:00+00:00 List-Id: Robert A Duff wrote: > > "Samuel T. Harris" writes: > > > Certainly I can. Since [] and {} are not legal Ada tokens, > > they many only appear in comments and string literals. > > A syntax to handle these so that other [] and {} > > are converted to () is trivial to do. > > No, I don't think it's trivial to do it right. > > Consider: > > procedure Main is > function F return String is > begin > return "A"; > end F; > > procedure Nested is > function F(X: Integer) return Character is > begin > return 'B'; > end F; > begin > Text_IO.Put(F[1]); -- Not Ada. > end Nested; > begin > Nested; > end Main; > > Presumably the F[1] above resolves to the outer F, which returns an > array, so the program prints "A". If you "trivially" transform "[...]" > into "(...)" you will get an illegal (ambiguous) Ada program. > > - Bob In supporting [] for arrays and {} for aggregates, I did not mean to imply changing any Ada semantics. They simply make the recognizer grammar much simpler since () isn't used for so many things. Indeed, I have said previously that I want as much Ada semantics as is reasonbly feasible. If F(1) is ambiguous in Ada, then so should F[1] be ambiguous in the scripting language. Using [] for arrays is a syntactic short-cut enabling a much simpler grammar. Semantics don't have to be similarly "simplistic". Indeed, I'd expect the script interpreter to say something more than just that I have an ambiguous reference. I'd expect to say something like I have an ambiguous reference between an intended array subscript and an homogenenous function call. I failed to mention before that I feel the substitution of [] and {} would be akin to using % instead of ", : instead of #, and ! instead of | except that instead of being optional, [] and {} are mandatory. In this way, the syntax of array index does not have to be boggled with named notation since the explicit delimiters [] do not allow named notation. So I don't need syntax non-terminals such as function_call_or_array_index_or_qualified_aggregate with all the complexity involved. The semantics still have to verify the appropriate nature of the element. Given this, I believe you would agree that the substitution of () for [] and {} would now be trivial. Problem cases such as the one you cite above should not allowed by the semantics of the Ada interpreter. Otherwise, I see no benefit to using these special substitutions except to satisfy the expectations of prior experience with other languages. -- Samuel T. Harris, Principal Engineer Raytheon, Aerospace Engineering Services "If you can make it, We can fake it!"