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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,d2e2f8b6578a7759 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-22 08:15:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!chcgil2-snh1.gtei.net!news.gtei.net!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: Subject: Re: some simple questions X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: NNTP-Posting-Host: 12.211.13.75 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc52.ops.asp.att.net 1045930528 12.211.13.75 (Sat, 22 Feb 2003 16:15:28 GMT) NNTP-Posting-Date: Sat, 22 Feb 2003 16:15:28 GMT Organization: AT&T Broadband Date: Sat, 22 Feb 2003 16:15:28 GMT Xref: archiver1.google.com comp.lang.ada:34427 Date: 2003-02-22T16:15:28+00:00 List-Id: "Daniel Sch�le" wrote in message news:b36b5m$p0i$1@news.rz.uni-karlsruhe.de... > Hi all > > I am learning Ada on doing > I have found some small examples on web and > now I'm trying to put the mosaic stones together > > my questions are > > given > type pint is access integer; > pi: pint:=new integer; > > how do I delete the allocated object? > free(pi); --doesn't work > (I'm pretty sure Ada doesn't have Garabge Collector) > > is there a syntax available to initialize allocated object (like in C++)? > int * pi=new int(0); > now I am doing that this way > pi.all:=0; > If you add: procedure free is new ada.unchecked_deallocation( integer, pint ); Then free(pi) works. Since Ada is a type-safe language, you can't use the same function on any old type of variable. Generics are a way of creating generic functions and procedures where you can specify a specific type by creating an instance of the function or procedure. The standard library for Ada includes a generic procedure for deallocating memory. You create an instance of the deallocator for your specifc type as shown above. Since you're new to Ada, I suggest perusing the standard library of functions which you'll find at: http://www.adaic.org/standards/95lrm/html/RM-A.html The reference manual isn't very good for learning Ada, but it is a good reference for the functions in the standard library. You will find a number of books on Ada at: http://www.adapower.com/books/ > what is the proper way to assure that pointer points to valid object? When you declare an access variable in Ada, it is set to null by default. Usually you can test for a valid pointer by testing for null. > and last one > what's "std::system("clear");" translated to Ada > (OS Linux) > I can only guess on this one (you'll probably get an answer from someone else). Here's my guess: If the profile for system looks something like: int system( char *str ); Then in Ada you can use that function by declaring: function System( str : Interfaces.C.Strings.Char_Array_Access ) return integer; pragma Import( C, System, "system" ); And then treating the function just as you would any other Ada function. One of Ada's strong points is interfacing with other languages. I hope this helps, Steve (The Duck) > sorry if it's faq > > Thanks > > Daniel > >