I have this proc in some Tcl
proc AddType {type} {
set map (...code to create the map here...)
if {[info exists map("$type")]} {
set frame $map("$type")
} else {
set frame [MakeFrame]
}
}
which works correctly. Unfortunately, something in the middle of it "breaks" Notepad++'s syntax highlighting, such that it shows like this:
If I change $map("$type")
to $map( "$type")
then all is happy in terms of the syntax highlighting:
however the Tcl then fails to load. This is some legacy Tcl, and this proc is near the start of a pretty large file and all of the syntax highlighting is wrong from this point to the end of the file, so it's pretty irritating.
Is there another way to rework that array access such that it still works and such that Notepad++'s syntax highlighting will be happy?
info exists
will return false, as you've done aset map [something]
immediately above, guaranteeing thatmap
is not an array… – Donal Fellows