Ada 2005?

conradwt_at_runbox.com
Date: 12/18/04

  • Next message: Martin Dowie: "Re: Ada 2005?"
    Date: 17 Dec 2004 20:27:44 -0800
    
    

    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:

    // C++

    class A_Device {

    public:

    A_Device( char*, int, int );

    char* Name( void );

    int Major( void );

    int Minor( void );

    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;

    function Create( Name : String,
    Major : Integer,
    Minor : Integer ) return Device_Type;

    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.

    -Conrad


  • Next message: Martin Dowie: "Re: Ada 2005?"

    Relevant Pages