Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[namespace export -clear] surprise

Closed / Fixed3605447fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2013-02-20 17:36:20
% namespace export
% namespace export x
% namespace export
x
% namespace export -clear y
% namespace export
y
% namespace export z
% namespace export
y z
% namespace export -clear
% namespace export
y z

The last round is the surprise.  The failure of the -clear option
to do any clearing unless new patterns come in at the same time
is not what I expected, and not the interpretation I would make of
the documented behavior.  It sure appears that there's no way
to return a namespace's export list to a list of no patterns.  The
behavior of

namespace export -clear $newExportPatternList

is also fraught with complication of the Do Nothing Gracefully
variety.

If this isn't a bug, it ought to be.  Ick.
dgpplain2013-02-21 00:41:15
That last example ought to be

namespace export -clear {*}$newExportPatternList
dgpplain2013-02-21 00:45:58
To some extent this is the badness of the Tcl_Export()
interface leaking through.  Double Ick.
dgpplain2013-02-21 00:56:10
Heh.  The way to get back to any empty export list
is, apparently:

% namespace export x
% namespace export
x
% catch {namespace export -clear bad::data}
1
% namespace export
% 

Who wants to make the case this is a sensible
intentional interface?  Bleah.
dgpplain2013-02-21 02:19:30
See bug-3605447 branch for something more sensible.
Test suite does not care about the change.
dkfplain2013-02-21 04:08:04
[catch {namespace export -clear bad::data}]??? That's... that's gotta change.

If you're doing this, you might consider adding "--" support. (Yes, it makes it more of a change, with more risk, but it's likely to reduce the actual WTF content.)
dgpplain2013-02-21 10:20:49
allow_comments - 1

fix merged on all active branches
Log in (anonymous is fine) to add a comment.