There is an articly presenting a syntax that is "class" like at:
http://www.adahome.com/articles/1998-02/ar_lessons95.html
I tend to like the idea that the syntax of the language is loose and
allows me to use the form that works best for the individual class /
package.
(more below)
David Botton
---Nasser Abbasi <[log in to unmask]> wrote:
>
> At Sun, 15 Nov 1998 17:36:29 +0100
> >
>
> it is more than just "synatx".
>
Only if you are sloppy about your coding policy.
> The C++/Java syntax (refered to as above, above) for a class is more
> natural to me becuase it allows one to write
>
> Obj.message( message_parameters );
>
Ada lets your write:
result := getMax ( From => Sensor );
or
putMinimum ( InTo => Sensor );
Seems a lot more natural to me.
> instead of the Ada way, where one writes
>
> message( some_parameters, the_object_is_hidden_here ,
> some_other_message_parameters);
>
> You see, in the Ada way, the object whose the message is being send to
> is hidden among the message parameters being send to it!
>
Again, only if you are sloppy.
> Using a function/procedure call to send a message to an object, and
> having the object the message being send to sit among the parameters
of
> the message is not a natural way to express what I think of when I
think
> of objects and messages being send between them. .
>
> Not only that, it is visually harder in Ada to find the stuff that
makes
> what is contained in a "class", since there is no one enclosing
> construct the contains the data+methods in one place.
That is what the package does for you.
> There is nothing
> to stop anyone of having methods (functions, procedures) that do not
> belong to the "class" from being spread all over the package and in
> between the primitive methods of other tagged records.
That is the best part. I can define supporting non-OO procedures and
methods in the same place as the class. Even more importantly,
restraints (subtypes) and types that will give me compile and run time
safety.
>
> It is harder becuase you have to look at the profile of each
function or
> procedure to determine that that method belongs to what tagged record,
> by visually inspecting the arguments to find if one of them is of
tagged
> record type, or even what the return type of the function is.
>
Unless you are sloppy, you lay things out to please the reader. Of
course when you need to, you can deviate, unlike other languages.
> this loose organization is what bothers me about how Ada handles OO. I
> like to see all the stuff that belongs to one class encapulated in a
> clear construct, something like
>
> class class_name
> {
> // everything here belongs to this class.
> }
>
> now I am happy, I dont have to scan the code visually to decide what
> belongs and what does not belong to the class 'class_name'.
I just wish the Ada95 team had made "class" a synonym for package so
the Ada world would not have to spend time on "Where is the class
keyword?"
>
> Offcourse, everyone is free to prefer different styles, I just find
the
> OO style of Java and C++ more natural, even though I like all the
other
> Ada language stuff more, except for its OO.
>
> Nasser
>
It is the semantics that are important not the syntax, and a
preprocessor could make your syntax problems go away.
(like #define class package)
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
|