At the moment when I want a class to provide a const I write code like this:
oo::singleton create Mplayer {}
oo::define Mplayer initialize {
variable FILETYPES
const FILETYPES {{{Audio Files} {.mp3 .ogg}}}
}
oo::define Mplayer classmethod filetypes {} {
variable FILETYPES
return $FILETYPES
}
This means I can access the const outside the class using the method, e.g.,
set filename [tk_getOpenFile -filetypes [Mplayer filetypes] ...]
I was wondering if there was a shorter/better way to do this?
Am 19.12.2025 um 09:20 schrieb Mark Summerfield:
At the moment when I want a class to provide a const I write code like this: >>
oo::singleton create Mplayer {}
oo::define Mplayer initialize {
variable FILETYPES
const FILETYPES {{{Audio Files} {.mp3 .ogg}}}
}
oo::define Mplayer classmethod filetypes {} {
variable FILETYPES
return $FILETYPES
}
This means I can access the const outside the class using the method, e.g., >>
set filename [tk_getOpenFile -filetypes [Mplayer filetypes] ...]
I was wondering if there was a shorter/better way to do this?
I am not so much in Tcl-OO, but Tcl 9.0 has a const keyword. https://core.tcl-lang.org/tips/doc/trunk/tip/677.md
Maybe, this might help.
THanks for all,
Harald
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 54 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 14:12:05 |
| Calls: | 742 |
| Files: | 1,218 |
| D/L today: |
3 files (2,681K bytes) |
| Messages: | 183,842 |
| Posted today: | 1 |