This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tapsets/13721] local variable name collision


http://sourceware.org/bugzilla/show_bug.cgi?id=13721

Josh Stone <jistone at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jistone at redhat dot com

--- Comment #1 from Josh Stone <jistone at redhat dot com> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]