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,7f4d16c4ee371eb5 X-Google-Attributes: gid103376,public From: Paul Graham Subject: Re: Why is it Called a Package? Date: 2000/04/07 Message-ID: <38EE12F4.7972A964@cadence.com>#1/1 X-Deja-AN: 608059361 Content-Transfer-Encoding: 7bit References: <38DF7F38.8D656ABD@lmtas.lmco.com> <38DFB0BC.9FF72EFC@callnetuk.com> <87u2hq857e.fsf@deneb.cygnus.argh.org> <38E2A4A4.E59E997C@research.canon.com.au> <8ck2mt$jrn$1@clnews.edf.fr> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Cadence Design Systems Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-04-07T00:00:00+00:00 List-Id: Pascal Obry wrote: > I don't think we want that. A very nice consequence here is that you can > easily change an abstraction from: > > package P is > Some_Value : array (1 .. 10) of Integer; > -- first quick implementation using basic array > end P; > > to > > package P is > function Some_Value (N : in Positive) return Integer; > -- real implementation using a complex structure > end P; > > (or the other way around) without modifying all client code. What about: x := Some_Value(1 .. 3); Changing the implementation from an array to a function is not so easy here. If for efficiency reasons you want to re-implement a function as an array lookup, why not just write a public function as an interface to a private array, then inline it? I've always thought that using [] for indexing, slicing, and aggregates would have made the language much simpler. How many times have you Ada experts had to explain to someone that (1) is not a legal array aggregate? Another thing that has always bothered me is the omission of parentheses in a subprogram without arguments. It results in some peculiar corner cases in the language. For instance, sometimes f.x means variable x declared within function f, and sometimes it is a call to f returning a record (or an access to record :-) with element x selected. And I seem to remember some ambiguities with attributes of sbprograms: is f'some_attribute an attribute of the function f or of the value returned by f. Sure, the LRM has rules to resolve these ambiguities, but why introduce the ambiguities in the first place? Paul