Overview
| Artifact ID: | 8bdba0dc555d434a61040d8cfdf6fc7167cfe6c6b32cea397572620ce70a1b4b |
|---|---|
| Ticket: | 8f741de59dbc79b0d6e1b71abe338391081492f5
switch compilation difference with end of opts marker |
| User & Date: | juliannoble2 on 2025-11-10 08:47:37 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-plain"
- comment changed to:
The below comment block in tclCompCmdSz.c suggests the intention is for switch -exact word {pattern body ...} to be treated the same as switch -exact -- word {pattern body ...} as far as compilation is concerned. Similarly for -glob and -regexp However, the -- seems to be required for the compilation to proceed as after the option processing loop we have: if (numWords < 3) { return TCL_ERROR; } #comments from tclCompCmdsSZ.c TclCompileSwitchCmd # /* # * Only handle the following versions: # * switch ?--? word {pattern body ...} # * switch -exact ?--? word {pattern body ...} # * switch -glob ?--? word {pattern body ...} # * switch -regexp ?--? word {pattern body ...} # * switch -- word simpleWordPattern simpleWordBody ... # * switch -exact -- word simpleWordPattern simpleWordBody ... # * switch -glob -- word simpleWordPattern simpleWordBody ... # * switch -regexp -- word simpleWordPattern simpleWordBody ... # * When the mode is -glob, can also handle a -nocase flag. # * # * First off, we don't care how the command's word was generated; we're # * compiling it anyway! So skip it... # */ It is verifiable with tcl::unsupported::disassemble that (for the combined pattern body versions) switch -exact word {pattern body ...} compiles differently to switch -exact -- word {pattern body ...} (as with -glob and -exact) Is this intentional? It seems at odds with the comment block and also the switch man page states for the end of options marker: "This is not required when the matching patterns and bodies are grouped together in a single argument." Well it's not *required* as such - but it seems to me it is required if you want the best performance from a switch statement. - is_private changed to: "0"
- login: "juliannoble2"
- priority changed to: "5 Medium"
- private_contact changed to: "957fdfcd8744611e3fe1f4896c7538b1d9bf47b2"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "juliannoble2"
- subsystem changed to: "18. Commands M-Z"
- title changed to:
switch compilation difference with end of opts marker
- type changed to: "Bug"