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,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-25 16:34:06 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail From: "Ekkehard Morgenstern" Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada Date: Wed, 26 Nov 2003 01:34:04 +0100 Organization: 1&1 Internet AG Message-ID: References: NNTP-Posting-Host: p508c004b.dip0.t-ipconnect.de X-Trace: online.de 1069806845 5205 80.140.0.75 (26 Nov 2003 00:34:05 GMT) X-Complaints-To: abuse@einsundeins.com NNTP-Posting-Date: Wed, 26 Nov 2003 00:34:05 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Xref: archiver1.google.com comp.lang.ada:2946 Date: 2003-11-26T01:34:04+01:00 List-Id: "Randy Brukardt" schrieb im Newsbeitrag news:vs7eaf1kispja1@corp.supernews.com... > "Ekkehard Morgenstern" wrote in message > > > Like, when I declare a procedure > > > > procedure A ( B: in access all T'Class ) > > > > could I use a different method and still get all the benefits of Ada > > object-oriented programming? > > Yikes! The "in" isn't allowed here, nor is the "all" -- they're both > assumed. "in" is allowed, even if assumed. :-) the "access all T'Class" part produces an error message with the compiler, but I meant that to be exemplary anyway (to save me from typing an extra "type" statement). > Second, you are generally best off avoiding access types when you can. That > certainly is true of O-O programming as well. Use access types for dynamic > structures; don't use them otherwise. > > procedure A (B : in out T'Class); How do I assign an object of type T to an access to T'Class? Like, I have a node class, type Node; type Node_Ptr is access Node'Class; type Node is tagged record Succ : Node_Ptr; Pred : Node_Ptr; end record; and a method like procedure NextNode( Node_Obj : in out Node'Class ); how do I assign a Node to a Node_Ptr? > When we designed Claw (a thick O-O interface for Windows), we avoided use of > access types in the interface in almost all cases. There are a lot of access > types in the implementation, but the user of Claw doesn't need to worry > about that. That's especially useful for simple programs (for instance, > those that declare just a few windows), because Ada can do all of the > storage management. How can I exploit Ada's storage management to the max? Especially when I have things like Lists and Nodes, Queues etc. or other container classes? > Ada allows access types for O-O programming because of a desire to allow > people to translate existing O-O designs for C++ and Java directly into Ad a. > I think that's generally a mistake -- Ada can do better than using explicit > pointers. How can I design it better? :-) Do you know any good Ada programming style guides? BTW, that Claw project of yours, is that a commercial product, or is it free-/shareware? And where'd I get it from? :-) (you can also e-mail me about the details, I'm curious to know! :-) -- I might want to interface to Windows in Ada, I want to avoid using the outdated Win32Ada, or are there newer versions?)