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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9af30ff1a54d60cf X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Ada 95 OOP questions Date: 1996/08/17 Message-ID: #1/1 X-Deja-AN: 174772291 references: <9608141717.AA08650@most> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-08-17T00:00:00+00:00 List-Id: 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