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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!ncrlnk!ncrcae!hubcap!gatech!cwjcc!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!uw-june!pattis From: pattis@june.cs.washington.edu (Richard Pattis) Newsgroups: comp.lang.ada Subject: Re: Ada language revision Summary: Opaque vs. Private Types Message-ID: <6516@june.cs.washington.edu> Date: 23 Nov 88 21:14:17 GMT References: <44449@beno.seismo.CSS.GOV> <3563@hubcap.UUCP> <7882@nsc.nsc.com> <6843@pyr.gatech.EDU> Organization: U of Washington, Computer Science, Seattle List-Id: In article <6843@pyr.gatech.EDU>, tynor@pyr.gatech.EDU (Steve Tynor) writes: > Here, here. I think the Modula 2 compromise of requiring 'opaque' types to be > pointers is adequate. This way there is enough information supplied in the > specification for code generation in client packages, but the implementation > details are not broadcast. Sure, the code may be slightly less efficient > (since you're forced to use a pointer), but I've rarely run into a situation > where I've wanted to create an ADT where a pointer (ok, ok, 'access > type') wasn't the natural representation anyway... > > Steve Tynor > Georgia Tech Research Institute > tynor@gitpyr.gatech.edu As someone who has taught Modula-2 in introductory courses for 4 years (4 times a year) I've voted with my feet and switched to Ada. Private types are one reason. While opaque types do allow for easier portability, and a link time decision of which imlementation to use, there are some drawbacks. For teaching, the concept of a protected object is important and is easy to motivate. But by requiring students to learn about dynamic allocation and deallocation to implement such a type, Modula-2 makes it very hard for me to intoduce this concept early. Also, the newest M-2 standard (at least that I have seen) proposes to restrict opaque types to pointer only, disallowing me to define an opaque cursor that in one instance must be implement by integer that refers to some location in an array. Also, there are all sorts of problems with initialization/finalization in Modula-2's opaque types. Try writing a complex number type and functional versions of the standard arithmetic operators, including garbage collection. Finally, if I recall my Ada correctly, one can use access types in Ada to implement private types that are equivalent to Modula-2's opaque types, at least with regard to portability problems residing in package bodies. I believe Cohen's book had a discussion of this use of access types in the private parts of packages.