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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3d9acd0750841603 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!x69g2000cwx.googlegroups.com!not-for-mail From: claude.simon@equipement.gouv.fr Newsgroups: comp.lang.ada Subject: Re: How to hide type internals Date: 30 Jun 2006 04:19:11 -0700 Organization: http://groups.google.com Message-ID: <1151666351.044613.327270@x69g2000cwx.googlegroups.com> References: <1151664636.528401.15590@d56g2000cwd.googlegroups.com> NNTP-Posting-Host: 212.23.162.39 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1151666354 17387 127.0.0.1 (30 Jun 2006 11:19:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 30 Jun 2006 11:19:14 +0000 (UTC) In-Reply-To: <1151664636.528401.15590@d56g2000cwd.googlegroups.com> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 sesame.setra.fr:8080 (squid/2.5.STABLE3) Complaints-To: groups-abuse@google.com Injection-Info: x69g2000cwx.googlegroups.com; posting-host=212.23.162.39; posting-account=SnKwIw0AAABJwJI8idy3oqasZLmqdeAT Xref: g2news2.google.com comp.lang.ada:5330 Date: 2006-06-30T04:19:11-07:00 List-Id: Gerd a =E9crit : > Hi, > > I would like to write a package that exports functions using a special > type, without showing the details in the spec (even not in the private > part). > In Modula-2 one can declare opaque types (which mostly are pointers but > also can be any type of word size). > Like this: > > package keys is > type key; > function GetKey return key; > procedure FetchElement (k : key); > -- implementation of key not visible here > end keys; > > package body keys > ... > type Data is record > ... > end record; > type key is access Data; > ... > end keys; package Keys is type Key is private; function Getkey return Key; -- ... private type Imp_Key; -- deferred type to the body type Key is access Imp_Key; end Keys; package body Keys is type Imp_Key is new Integer; -- whatever type function Getkey return Key is The_Key : Key :=3D new Imp_Key; begin return The_Key; end GetKey; end Keys;