|
2017-05-02
| ||
| 10:31 | • Ticket [f27930150a] namespace ensemble subcommands with the empty string for a n... artifact: 45cb3f4896 user: dkf | |
| 10:31 | • Closed ticket [f27930150a]. artifact: 434764c05c user: dkf | |
|
2017-04-28
| ||
| 15:39 | • Ticket [f27930150a]: 3 changes artifact: 38a6c672ab user: aspect | |
| 13:47 | • New ticket [f27930150a]. artifact: 4f49fe57f4 user: pooryorick | |
namespace ensemble subcommands with the empty string for a name
Closed / Invalidf27930150a84a15b8becb835dae45674fa41b0c5Created 10 years agoUpdated 10 years ago
Descriptionwiki2017-04-28 13:47:00
Some wild ensemble command behaviour when the name of the subcommand is the
empty string:
namespace eval n1 {
namespace export *
namespace ensemble create
namespace ensemble configure [namespace current] -map {
p1 {::puts yada}
}
}
n1 {} ;# -> yada
proc n1:: {} {puts foo}
n1 {} ;# -> yada
namespace ensemble configure n1 -map {} ;
n1 {} ;# -> foo
namespace ensemble configure n1 -map {p1 {::puts yada} p2 {::puts bar}}
n1 {} ;#-> unknown or ambiguous subcommand "": must be p1, or p2
aspectplain2017-04-28 15:39:16
This is a result of the default configuration `-prefixes true`: {} is an unambiguous prefix of p1.
dkfhtml2017-05-02 10:31:01
The behaviour you describe is correct. There is no bug.
When an ensemble has an empty -map (and empty -subcommands list), it uses the exported commands of the namespace as the set of subcommands. When an ensemble has a non-empty -map, it uses the keys of that map to determine what the set of subcommands is. In both cases, it then finds whether there is an exact match for the subcommand name against its set of possible subcommands, and if there is no exact match and the -prefix option is true (the default), then sees whether the provided subcommand name is a prefix of exactly one subcommand name. (If there's two or more subcommands that could match, that's an error. The empty string is a prefix of all other strings of course.)
dkf Ticket [f27930150a]: 4 changes
[History diff]2017-05-02 10:31:40
Log in (anonymous is fine) to add a comment.