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,131f06967722ab4b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!feed.news.tiscali.de!blackbush.cw.net!cw.net!newsfeed.stueberl.de!newsr1.ipcore.viaginterkom.de!news-peer1!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: Martin Dowie Newsgroups: comp.lang.ada Subject: Re: Ada 2005? Date: Sat, 18 Dec 2004 08:08:52 +0000 (UTC) Organization: BT Openworld Message-ID: References: <1103344064.372396.51420@c13g2000cwb.googlegroups.com> NNTP-Posting-Host: host81-152-56-142.range81-152.btcentralplus.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: titan.btinternet.com 1103357332 3395 81.152.56.142 (18 Dec 2004 08:08:52 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Sat, 18 Dec 2004 08:08:52 +0000 (UTC) In-Reply-To: <1103344064.372396.51420@c13g2000cwb.googlegroups.com> X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) Xref: g2news1.google.com comp.lang.ada:7044 Date: 2004-12-18T08:08:52+00:00 List-Id: conradwt@runbox.com wrote: > Hi, will Ada support keyword class for designing and implementing > classes? For example, I'm forced to convert the following C++ class in > Ada as follows: Why are you hung up on having a keyword 'class'? 'Tagged types' in Ada do the same thing wrt dynamic dispatching and 'packages' give you namespaces/modules. > // C++ > > class A_Device { > > public: > > A_Device( char*, int, int ); "char*" really ought to be a 'const'... > char* Name( void ); > > int Major( void ); > > int Minor( void ); These really ought to be marked as 'const' functions... > protected: > > char* name; > > int major; > > int minor; > }; > > // Now, if I need to interact with the, this class I can do the > // following: > > void main(void) { > > A_Device aDevice = new A_Device( "Test", 1, 1 ); > > cout << aDevice.Name() << endl; > cout << aDevice.Major() << endl; > cout << aDevice.Minor() << endl; > > } > > // Ada > > package Devices is > > type Device is tagged private; > > type Device_Type is access private; You just don't need this access type > function Create( Name : String, > Major : Integer, > Minor : Integer ) return Device_Type; Just return something of type Device... > function Name( this : Device_Type ) return String; > > function Major( this : Device_Type ) return Integer; > > function Minor( this : Device_Type ) return Integer; > > private > > type Device is tagged > > record > > name : String(1..20); > major: Integer; > minor: Integer; > > end record; > > end Devices; > > Now, interact with Ada package I would need to do the following: > > procedure main > > aDevice : Device_Type := Devices.Create( "Test", 1, 1 ); > > begin > > Put_Line( Name( aDevice ) ); > Put_Line( Major( aDevice ) ); > Put_line( Minor( aDevice ) ); > > end main; > > It seems that I'm trying to mimic the behavior of a OO language in a > procedural language when converting C++ to Ada. Is this correct? If > so, why doesn't Ada have OO contructs similar to C++, > Java, Eiffel, and Smalltalk to name a few where one passes a message to > an instance of a class? Will this be something in Ada 2005 because I > have been able to find a good overview of the language to date? Well, > I must go and thanks for any comments that you may send me. Ada does have OO behaviour - what isn't OO about the behaviour of a 'tagged type'? If you're bother that you can't say "Put_Line (aDevice.Name);" then wait for Ada200Y which adds this. But it is nothing more than playing with syntax - there is no symantic difference to this notation that to: Put_Line (Name (aDevice)); Cheers -- Martin