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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news.stack.nl!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Seeking for papers about tagged types vs access to subprograms Date: Mon, 13 May 2013 21:14:42 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <19lrzzbgm77v6.1dzpgqckptaj6.dlg@40tude.net> <1bfhq7jo34xpi.p8n2vq6yjsea.dlg@40tude.net> <12gn9wvv1gwfk.10ikfju4rzmnj.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1368497687 8361 69.95.181.76 (14 May 2013 02:14:47 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 14 May 2013 02:14:47 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Original-Bytes: 3726 Xref: number.nntp.dca.giganews.com comp.lang.ada:181624 Date: 2013-05-13T21:14:42-05:00 List-Id: "Robert A Duff" wrote in message news:wccmwrzu9oj.fsf@shell01.TheWorld.com... > Jeffrey Carter writes: > >> I'm not sure I see the point in having an object for a closed file, > > Yeah, I was about to post basically the same thing. A closed file > is pretty useless. It's like an uninitialized variable -- you can't > do anything with it. Yes, and of course Ada allows uninitialized variables, too. Clearly the same sorts of reasons apply. We briefly tried that model when designing Claw, but it really didn't work, because the underlying handle can be closed by some other operation and in that case the object becomes closed (we called it "invalid") without any explicit action in your code. For a windowing system, that other operation can be the guy with the mouse, who can easily screw up all of your carefully thought out code. Another issue is that doing that means that you are limited to Ada's scopes for managing objects, which means that you're limited in how you can set up and tear down structures. (You can always get around those problems by essentially making your clients use new/unchecked_deallocation for everything -- but I don't consider that a step forward. I'd rather have "invalid" objects than force people to use access types.) We used that model throughout Claw, and that included in Claw.Directories, so of course it carried over into the original proposal for Ada.Directories (which was heavily based on Claw.Directories). So "Search_Type" originally had a "Is_Valid" routine, which eventually got folded into "More_Entries". (Which demonstrates an intermediate approach that often works -- have a default initial state which is well-defined but not useful.) Randy.