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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d80cdc1b3ff5b2f9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-14 14:42:22 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-01!supernews.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Simple Question 3 References: <9qcmt9$8n1$1@newsg1.svr.pol.co.uk> X-Newsreader: Tom's custom newsreader Message-ID: <2Fny7.17385$gT6.10077588@news1.rdc1.sfba.home.com> Date: Sun, 14 Oct 2001 21:42:22 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 1003095742 24.7.82.199 (Sun, 14 Oct 2001 14:42:22 PDT) NNTP-Posting-Date: Sun, 14 Oct 2001 14:42:22 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:14489 Date: 2001-10-14T21:42:22+00:00 List-Id: > question of what a primitive operation is! Is it a function/procedure which > takes a derived type parameter and/or returns a derived type? Or is it just > functions which return a derived type only? The former. > Why does returning a derived type seem to have > more rules about what must be later declared in a derived type, than > function/procedures that just take that derived type as a parameter? > ... > The way the compiler is behaving, its as if it only takes into account > "out" parameters and does not care what "in" parameters look like. If an object of MyTestType1 is an input parameter to a function or procedure, it's safe to inherit since the function/procedure will simply not know about, and thus ignore, any later extensions in objects of type MyTestType2. If it's an output result, however, the function or procedure needs to be able to create an object with all of its extensions values. That is only possible if the function/procedure is declared after MyTestType2 is declared, so it knows about those extensions and can set them to appropriate values. > function UnitA(a: MyTestType1) return Integer; > function UnitB(a: MyTestType1) return MyTestType1; > function UnitC return MyTestType1; > UnitA() does not get flagged by the compiler as needing to be declared for > MyTestType2. But UnitB() and UnitC() do! But they all hold enough type > information for the compiler to be "intelligent" enough to know where static > matching takes place or not. Yes indeed, the compiler does know whether static matching takes place. It sounds like you want the compiler to flag any *use* of UnitB or UnitC where the left side of the assignment statement does not match, but you want the compiler to allow the *declaration*. Right? If you were painting the floor in a room, you might like to paint a thin part just inside the doorway, knowing that you could step over it and get out of the room. The compiler is saying, "whoa, you can't start your painting from just inside the doorway because you'll paint yourself into a corner". It's easy enough to avoid the problem by standing outside the doorway to do your painting. Similarly, as pointed out by Jean-Marc Bourguet, there are easy ways to declare Unit as a non-primitive operation.