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!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.erje.net!eu.feeder.erje.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Seeking for papers about tagged types vs access to subprograms Date: Tue, 14 May 2013 15:35:55 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1bfhq7jo34xpi.p8n2vq6yjsea.dlg@40tude.net> <12gn9wvv1gwfk.10ikfju4rzmnj.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1368560156 30115 192.74.137.71 (14 May 2013 19:35:56 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 14 May 2013 19:35:56 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:aoWFvylhUdVFynXEv0/bu2zTKU0= X-Original-Bytes: 3791 Xref: number.nntp.dca.giganews.com comp.lang.ada:181640 Date: 2013-05-14T15:35:55-04:00 List-Id: "Randy Brukardt" writes: > Yes, and of course Ada allows uninitialized variables, too. Clearly the same > sorts of reasons apply. Yes. I think what's missing is an ability to initialize an object after creating it (either by declaring it, or via "new"). My hobby language has that. And it distinguishes syntactically between initialization and assignment_statement. Ada uses ":=" for both, so if you do: F : constant File_Type; -- Illegal! ... -- calculate File_Name F := Open (File_Name); -- Illegal! that last statement is an assignment_statement in Ada, whereas it is conceptually an initialization. (That's illegal in Ada, because F is declared 'constant'. You can erase 'constant', but it's STILL illegal, because File_Type is a build-in-place limited type.) > 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. So how does it work in CLAW? Are you talking about some task writing into a window, while the user is asynchronously clicking on "close window"? So that task must be constantly checking Is_Open (or handling an exception), and locking things to make sure there are no race conditions? > 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. I think allowing to separate initialization from declaration can solve that. >...(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.) Agreed -- heap allocation solves the problem, but creates other problems. - Bob