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=0.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bb91141addc6c2c6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.228.227 with SMTP id sl3mr18793881pbc.5.1341761483295; Sun, 08 Jul 2012 08:31:23 -0700 (PDT) Path: l9ni11132pbj.0!nntp.google.com!news1.google.com!news.glorb.com!feeder.erje.net!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!reader03.nrc01.news.zen.net.uk.POSTED!not-for-mail From: Phil Thornley Newsgroups: comp.lang.ada Subject: Re: SPARK GPL 2012 and generic, any hint? Date: Sun, 8 Jul 2012 16:31:22 +0100 Message-ID: References: Reply-To: phil.jpthornley@gmail.com MIME-Version: 1.0 User-Agent: MicroPlanet-Gravity/3.0.4 Organization: Zen Internet NNTP-Posting-Host: 84eb4fe1.news.zen.co.uk X-Trace: DXC=KDfFK^25\9UaYWh7c\Cn3Tf2FgniPJjgR=dR0\ckLKGPWeZ<[7LZNRV0Sn:]m5L7^?ge[9T X-Complaints-To: abuse@zen.co.uk Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-07-08T16:31:22+01:00 List-Id: In article , hugues@soekris-1.pinkyoogx.org says... > > Hi, > > I tried SPARK GPL 2012 with a small example for generic, but I keep getting > syntax error, do I miss something obvious? > > The documentation lacks a complete example that can be processed, all I could > find was limited code snippet :( > > Here is the code source (code taken from SPARK GPL 2012 documentation, i > I simply added package stuff around) > > package Test is > > generic > type T1 is range <>; > type T2 is range <>; > --# check T1'Last * T1'Last <= T2'Last and > --# T1'First * T1'First <= T2'Last and > --# T1'First * T1'First >= T2'First; > function Square (X : T1) return T2; > --# return R => R = T2 (X * X); > > end Test; > The instantion check isn't supported yet, and the subprogram must be at library level. The following code examines OK: generic type T1 is range <>; type T2 is range <>; function Square (X : T1) return T2; --# return R => R = T2 (X * X); Cheers, Phil