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: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,096 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 366:05:54 |
| Calls: | 14,034 |
| Calls today: | 2 |
| Files: | 187,081 |
| D/L today: |
1,733 files (529M bytes) |
| Messages: | 2,478,509 |