comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Ada 95 OOP questions
Date: 1996/08/17
Date: 1996-08-17T00:00:00+00:00	[thread overview]
Message-ID: <dewar.840287285@schonberg> (raw)
In-Reply-To: 9608141717.AA08650@most


Wes says

"I offer a compromise to anyone who wants Ada to be more obvious about
the relationship between an object/class/type and its methods/operations."

And then suggests misusing protected types for this purpose. Why misuse?
Because protected types in Ada 95 are not a general abstraction mechnamism,
but rather a low level construct with severe restrictions on what can be
done inside the protected operations. The whole idea of protected operations
is that the operations themsleves should be short simple operations, and in
particular they cannot perform potentially blocking operations.

So advising the use of protected objects as a general replacement for
a class abstraction will pretty quickly get people into trouble!
Furthermore, they are likely to not realize that they are in trouble,
since compilers are not required to check dynamically for violating the
no-potentially-blocking-operations requiremens, and therefore you can
easily end up writing non-portable code without realizing it.

Let me give an example, suppose you have a library sort routine. Unknown
to you, the body of this sort declares tasks. Calling this sort routine
from within a protected operation means that your program has a bounded
error, and it might work on one compiler, and mysteriously deadlock on
some other implementation, or raise Program_Error (in practice the worry
is raising Program_Error, since although 9.5.1(17) allows deadlock to
occur, it probably is the intention that this be alloowed only if it
naturally makes sense that deadlock could arrive





      reply	other threads:[~1996-08-17  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-14  0:00 Ada 95 OOP questions W. Wesley Groleau (Wes)
1996-08-17  0:00 ` Robert Dewar [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox