TIP 471: Add [info linkedname] Introspection Command

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Mathieu Lafon <mlafon@gmail.com>
State:          Draft
Type:           Project
Created:        05-May-2017
Tcl-Version:    8.7
Vote:		Pending
Post-History:

Abstract

This TIP proposes to improve link variable introspection by providing a new info linkedname command.

Rationale

This TIP is related to discussions about [457] and the -upvar extended argument specifier. Adding an intropsection command to get the name of the variable linked to is more Tcl-ish than automatically adding a local variable with the linked name. The proposed command is not restricted to [457] usage as this can also be used for a link variable created by other means, using the upvar command for example.

Specification of the Proposed Change

There should be a new subcommand of info created with the following syntax:

info linkedname varname

The varname should be the name of a variable that has been linked to another variable (e.g., with upvar, global, variable or namespace upvar), and the result of the command will be the name of the variable linked to.

Reference Implementation

The reference implementation is available in the info-linkedname http://core.tcl.tk/tcl/timeline?r=info-linkedname branch.

The code is licensed under the BSD license.

Implementation Notes

Depending on the linked variable, the name is found using different methods:

Copyright

This document has been placed in the public domain.

History