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-Thread: 103376,5af5c381381ac5a7 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada requires too much typing! Date: Thu, 10 Jun 2010 23:09:53 +0300 Organization: Tidorum Ltd Message-ID: <87cv4iFqnfU1@mid.individual.net> References: <876j8vF54kU1@mid.individual.net> <4c0e2af7$0$7659$9b4e6d93@newsspool1.arcor-online.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Jla1nB/s8AxG43+iRvZjRQJLFgYm+CZZ6J+brxMmL+tiomJBg8 Cancel-Lock: sha1:4rM7w9tuvsR63Ul6FpP2122epHI= User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:12583 Date: 2010-06-10T23:09:53+03:00 List-Id: Simon Wright wrote: > Georg Bauhaus writes: > >> with Ada.Text_IO; use Ada.Text_IO; >> >> procedure Sttc is >> >> type T is range 0 .. 10; >> >> procedure A is >> package P is >> V: T; > pragma Export (C, V, "naughty_v"); --<<<<<<<<<< >> end P; >> begin >> if P.V'Valid then >> P.V := P.V + 1; >> else >> P.V := T'First; >> end if; >> Put_Line (T'Image(P.V)); >> end A; >> >> procedure Ovrwrt_Stk is >> X : T; >> begin >> X := T'First; >> end Ovrwrt_Stk; >> >> begin >> A; Ovrwrt_Stk; A; Ovrwrt_Stk; A; Ovrwrt_Stk; A; >> end Sttc; >> >> $ ./sttc >> 0 >> 1 >> 1 >> 1 >> $ >> >> Phew. Back to normal. > > $ gnatmake sttc -f -gnatVa > gcc -c -gnatVa sttc.adb > sttc.adb:10:28: warning: "V" has been made static as a result of Export > sttc.adb:10:28: warning: this usage is non-standard and non-portable > gnatbind -x sttc.ali > gnatlink sttc.ali > $ ./sttc > 1 > 2 > 3 > 4 > > (this is a GNAT-ism, of course, and is present in at least GNAT Pro > 3.16a1 for powerpc-wrs-vxworks and GCC 4.5.0 for x86_64-apple-darwin10). It is also present in GNAT 4.3 in debian lenny. You can even initialize V in its declaration, for example as V : T : = T'First, and GNAT will make this initialization happen once. No need for the unreliable trickery with 'Valid. Interesting curio to know, but as for using it... nah. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .