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,a00006d3c4735d70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-02-02 02:39:54 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!62.173.119.178!not-for-mail From: Peter Amey Newsgroups: comp.lang.ada Subject: Re: In-Out Parameters for functions Date: Mon, 02 Feb 2004 10:39:47 +0000 Message-ID: References: <1075159458.149886@master.nyc.kbcfp.com> <1075225041.167448@master.nyc.kbcfp.com> <1075303237.975898@master.nyc.kbcfp.com> <9khh10pti0dn8gcp7f18ghptaifluj0fud@4ax.com> <1075390647.405841@master.nyc.kbcfp.com> <1075405582.982776@master.nyc.kbcfp.com> <1075478950.231615@master.nyc.kbcfp.com> <1075490424.476589@master.nyc.kbcfp.com> NNTP-Posting-Host: 62.173.119.178 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1075718393 30565727 62.173.119.178 ([69815]) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en In-Reply-To: <1075490424.476589@master.nyc.kbcfp.com> Xref: archiver1.google.com comp.lang.ada:5177 Date: 2004-02-02T10:39:47+00:00 List-Id: [snip] > > By the way, I read the paper to which you referred. What happens > in SPARK if I have > package Sensor > --# own in State; > is > function Value return Integer; > --# global State; > end Sensor; > and I try to write > delta : Integer := Sensor.Value - Sensor.Value; You get a static semantic error: SPARK only allows variables and constants to be initialized by constant (i.e. fixed at compile time) expressions. Functions cannot be used. (There are other reasosn for this as well including avoidance of elaboration order dependencies). > > Can I write a function, not a procedure, which will return > different sensor values each time? Can I use them multiple > times in an expression? > No. There are special rules for volatile functions. They can only be used directly in simple assignment or return statements, not in general expressions. Peter