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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Seeking for papers about tagged types vs access to subprograms Date: Sun, 12 May 2013 10:49:31 +0200 Organization: Ada @ Home Message-ID: References: <19lrzzbgm77v6.1dzpgqckptaj6.dlg@40tude.net> <1bfhq7jo34xpi.p8n2vq6yjsea.dlg@40tude.net> <12gn9wvv1gwfk.10ikfju4rzmnj.dlg@40tude.net> NNTP-Posting-Host: 2WDySVo3ljzMoJ+IkbOqwg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.15 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 4251 Xref: number.nntp.dca.giganews.com comp.lang.ada:181601 Date: 2013-05-12T10:49:31+02:00 List-Id: Le Sun, 12 May 2013 10:10:01 +0200, Niklas Holsti = a =C3=A9crit: > You mean like this: > > function Open (File : in Closed_File) return Open_File; > function Close (File : in Open_File ) return Closed_File; > > I agree that this is a possible approach. This would work, but at the > cost of writing the parameter/object name twice in each call: Yes, that was that. I don't bother about writing more when it that makes= = things more readable. > File : File_Object; > ... > File :=3D Open (File); > File :=3D Close (File); > > But this code seems to cause a problem: > > File1, File2 : File_Object; > ... > File1 :=3D Open (File1); > File2 :=3D Close (File1); > > Now File2 is a clone of File1, and the underlying system file is close= d, > but File1 still considers it open. Interesting point. Note the the procedural way present the same issue, a= s = the object may be copied too, even if limited, using component by = component copy (as with actual Ada, the type cannot be private for the = reason given before). Less likely to occurs, but if it can occurs, it's = = enough to say the issue is still there. > > The "function" approach thus tends to clone objects, and to lose the > "object identity". The topic of object identity is interesting, I have not though about it.= = That's finally an issue similar to aliasing here=E2=80=A6 as the file ty= pe is = finally a kind of reference, via its handle. > If we want to preserve object identity under that approach, I think we= > need a "linear type system" > (http://en.wikipedia.org/wiki/Linear_type_system) Your nickname must Santa Clause :) Thanks for the new pointer, again. > Yes, that could be a problem. The language might allow the declaration= > of subtypes of opaque types, with opaque constraints. But the subtype would not have readable sense if the constraints would b= e = opaque. Or else as an alternative, may be Ada could allow partly unknown= = discriminant (something I miss): -- Valid actual Ada: type T1 (<>) is private; -- Invalid, actual Ada don't permits this: type T2 (Foo: Foo_Type; <>) is private; As an unrelated side note, something I miss too with private types, is t= he = ability for the completion to be a subtype (actual Ada requires it to be= a = type=E2=80=91new or a record). -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity