From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22278 invoked by alias); 21 Feb 2012 22:31:19 -0000 Received: (qmail 22270 invoked by uid 22791); 21 Feb 2012 22:31:18 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Feb 2012 22:31:06 +0000 From: "jistone at redhat dot com" To: systemtap@sourceware.org Subject: [Bug tapsets/13721] local variable name collision Date: Tue, 21 Feb 2012 22:31:00 -0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: systemtap X-Bugzilla-Component: tapsets X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jistone at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: systemtap at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2012-q1/txt/msg00165.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=13721 Josh Stone changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jistone at redhat dot com --- Comment #1 from Josh Stone 2012-02-21 22:30:29 UTC --- Ugh -- this is a common problem in languages without explicit declaration. We have declaration of globals, but we leave locals implicit. So here you actually are creating the global 'addr' just fine, but then port_from_xprt() is binding to that same global, rather than its usual local variable. Note that splitting these global/local instances based on conflicting type is not enough, since they could accidentally have the same type and still be wrongly associated. To really solve this, I think we'd need an (optional) explicit local declaration, and then use that consistently throughout the tapsets. For comparision, consider Python, where variables are bound to the scope in which they are written. To write to a variable in an outer scope, one must explicitly declare this using the "global" or "nonlocal" keywords. Reading variables works implicitly with the innermost scope that has bound that name. It would be too big a change for us to adopt Python semantics now, but we could resolve the current ambiguity in a similar way with a "local" keyword. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.