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-12 10:03:23 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!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: <9q6k2r$p8g$1@trog.dera.gov.uk> X-Newsreader: Tom's custom newsreader Message-ID: Date: Fri, 12 Oct 2001 17:03:22 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 1002906202 24.7.82.199 (Fri, 12 Oct 2001 10:03:22 PDT) NNTP-Posting-Date: Fri, 12 Oct 2001 10:03:22 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:14422 Date: 2001-10-12T17:03:22+00:00 List-Id: > > X := Unit; > > question: what is the value of X.c? > I would have thought that the compiler should just through the assignment X > := Unit() out, because it does not statically match. The compiler does indeed "throw out" the assignment statement. It gives you an error message saying it won't accept it. > I do not see why the compiler has the right to demand you write a Unit() > function for the derived type. Is there a deeper reason why it does? The function Unit supplies values for everything in X except X.c (the extension part). The compiler thus has no way of knowing what value it's supposed to give to X.c in the assignment. Perhaps in some languages the compiler would go ahead and let X.c take some random value, but an Ada compiler is more helpful than that and tells you that you are asking for garbage. An Ada compiler is not a dumb tool, like a hammer that can be used just as well on a thumb as on a nail. An Ada compiler is an assistant who helps you find errors and won't deliver hammer blows to your thumb.