❌ About FreshRSS

Reading view

There are new articles available, click to refresh the page.

Object-oriented methods in Ada

Having written Java code for a few decades, there are some facets that I find to be a β€œmust” (without having any good reason for it). One such thing is the way object-orientation makes use of methods. So, while I now try to learn myself Ada (have some PL/SQL experience), I find myself searching for method declaration.

As everyone who has coded Java knows, a method is written as a function within the class declaration. When the method is called, it is called as something that belongs to the class (or rather the object).

Ex. A Java class C may have a method m(x, y, …). And object o of class C can then use this method through the call:
o.m(x, y, …)

Having search (or skimmed) through both literature and the net, it is my understanding that the closet we get in Ada is to have a procedure or a function, with the first argument being of the containing type, declared in the type declaration, and then calling that proc/func by passing a variable of that type as the parameter (sorry if I mess this up, I know what I’m thinking, but putting it in writing is less clear). This would lead to a proc/func call similar to:

m(o, x, y, …)

Or have I missed something?

What is the β€œcorrect” object oriented way of writing the following in Ada?
public class Hello
{
public void SayHello()
{
System.out.println( β€œHello World!”);
}
}

And similar upon use:
{
Hello greeting = new Hello();
greeting.SayHello();
}

Your help and patience are appreciated.

:slight_smile: Roald

15 posts - 10 participants

Read full topic

❌