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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newshub.sdsu.edu!tiscali!newsfeed1.ip.tiscali.net!proxad.net!193.252.118.146.MISMATCH!news.wanadoo.fr!news.wanadoo.fr!not-for-mail Sender: obry@PASCAL Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <1110377260.350158.58730@z14g2000cwz.googlegroups.com> From: Pascal Obry Date: 09 Mar 2005 15:55:38 +0100 Message-ID: Organization: Home - http://www.obry.net User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Date: 09 Mar 2005 15:55:40 CET NNTP-Posting-Host: 82.120.30.69 X-Trace: 1110380140 news.wanadoo.fr 19339 82.120.30.69:4991 X-Complaints-To: abuse@wanadoo.fr Xref: g2news1.google.com comp.lang.ada:8935 comp.lang.c++:44769 comp.realtime:1128 comp.software-eng:4686 Date: 2005-03-09T15:55:40+01:00 List-Id: "Hans Malherbe" writes: > This looks like a limitation, but I'm not sure I understand correctly. Agreed. All this is somehow limiting. That's the trade off for the safetly. But when you are used to it, this limitations are not so bad, and quickly you can't live without them. > Example please! > > A few other questions: > > Do you have nested functions like Pascal have? Yes. > Can you access local variables? Of course yes. Otherwise what would local variables will be useful for? > Can you pass pointers to these functions around? Around no! The rules are strict here. This case is ok, P1 same level as PA. << procedure Demo is type PA is access procedure; procedure P (Proc : in PA) is begin null; end P; procedure P1 is begin null; end P1; procedure P2 is begin P (P1'Access); end P2; begin null; end Demo; >> This is not ok, P3 deeper than PA. << procedure Demo is type PA is access procedure; procedure P (Proc : in PA) is begin null; end P; procedure P1 is begin null; end P1; procedure P2 is procedure P3 is begin null; end P3; begin P (P3'Access); end P2; begin null; end Demo; >> Here is what GNAT reports for example: $ gnatmake demo gcc -c demo.adb demo.adb:22:10: subprogram must not be deeper than access type gnatmake: "demo.adb" compilation error No dangling pointers. > Can you pass non-type parameters (like the number 3.14) to templates? Yes. We can pass types, packages, procedure, functions, variables and constants. > Can templates recurse? Yes. > Can you program "const correct"? Eg. if you declare a member function > as const the compiler will help you not mutate the object or call any > functions that do. Also, if you pass a parameter as a const reference, > you will not be able to mutate the object the parameter references. Not sure to understand everything. But yes, if you have: Value : constant String := "whatever"; It will never be able to mutate Value. Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.obry.org --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595