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,21960280f1d61e84 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news3.google.com!homer!news.glorb.com!news-spur1.glorb.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!edtnps89.POSTED!023a3d7c!not-for-mail Sender: blaak@METROID Newsgroups: comp.lang.ada Subject: Re: in defense of GC References: <1169531612.200010.153120@38g2000cwa.googlegroups.com> <1mahvxskejxe1$.tx7bjdqyo2oj$.dlg@40tude.net> <2tfy9vgph3.fsf@hod.lan.m-e-leypold.de> <1g7m33bys8v4p.6p9cpsh3k031$.dlg@40tude.net> <14hm72xd3b0bq$.axktv523vay8$.dlg@40tude.net> <4zwt33xm4b.fsf@hod.lan.m-e-leypold.de> <1j7neot6h1udi$.14vp2aos6z9l8.dlg@40tude.net> <1pzx3y7d2pide.y744copm0ejb$.dlg@40tude.net> From: Ray Blaak Organization: The Transcend Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 06 Feb 2007 00:59:53 GMT NNTP-Posting-Host: 208.66.252.228 X-Trace: edtnps89 1170723593 208.66.252.228 (Mon, 05 Feb 2007 17:59:53 MST) NNTP-Posting-Date: Mon, 05 Feb 2007 17:59:53 MST Xref: g2news2.google.com comp.lang.ada:8991 Date: 2007-02-06T00:59:53+00:00 List-Id: Robert A Duff writes: > My complaint is that it's not specified by the programmer on the > declaration of that variable (mutable object). Some nested procedure > happens to mention N and that procedure gets returned to a more-global > place, dragging N along with it. I am wondering if your complaint is caused by strangeness of it all, rather than its actual detrimental effects. Consider a local pointer variable. You cannot tell from the declaration that the lifetime of the pointer will necessarily outlive its scope. Possibly it can, but some return call might pass it out, some might not. Some nested procedure might do so, some might not. You instead have to look to see the actual step of extension past its scope to know. I suppose that the pointer's declaration explicitly indicates heap allocation makes the essential difference to you. As a programmer you simply feel more in control of what is precisely happening. In languages with full closures, *any* local variable can outlive it's scope. That you cannot tell this from the variable itself does not bother me at all. Why should it? Local variables can only be captured by the lexical scoping of a nested procedure/closure. "Some nested procedure" should be very much obviously present and visible to the programmer. How big do methods on typical Ada projects get anyway? I tend to assume that a method is always under the control of a single programmer at a time. I would think that any fears you have about a local variable having an unexpected lifetime should also occur with the heap allocated values as well. After all they must be more carefully managed. It is just that with heap values you are naturally "on guard". Well, the presence of closure declarations provides a similar indication. Of course, without GC, things are quite a bit more dangerous, since it becomes quite a bit more difficult to reason when something can be safely freed. That might also explain the instinct to mistrust general closures. My question in the context of this example is how can a mutating local integer variable that outlives its scope be possibly dangerous? Only the closure is operating on it and nothing else. There are no heap issues to worry about. What is the possible harm? -- Cheers, The Rhythm is around me, The Rhythm has control. Ray Blaak The Rhythm is inside me, rAYblaaK@STRIPCAPStelus.net The Rhythm has my soul.