Skip to content
Tcl Source Code View Ticket
Login

View Ticket

oo::define supports classvariable but this is not really documented

Open858a615194b96b1e3d865bea1b1487b966e3dc24Created 1 year agoUpdated 326 days ago
Descriptionplain2025-10-08 09:23:33
On page https://www.tcl-lang.org/man/tcl9.0/TclCmd/define.html if you search for 'classvariable' you will find an example that shows how to create a class variable.

(1) There is no mention of classvariable on this page apart from the example. Surely there ought to be?

(2) There is no mention that it is possible to create class constants. However, "Emiliano" shows that this can be done: https://comp.lang.tcl.narkive.com/RtoJyYzS/are-class-consts-possible#post7 Again, shouldn't this be documented?
cduboisplain2026-01-12 03:55:53
Thanks for the report.

oo::define classvariable appears to be implemented and usable today, but it is missing from the formal command list on the oo::define manpage. I can put together a small doc patch to add it to the definitions section (with a short description alongside the other oo::define subcommands).

On “class constants”: as far as I can tell TclOO does not provide a dedicated constant mechanism, so what people do here is an idiom. I suggest we first fix the clear documentation omission for classvariable, and then (if maintainers agree) add a brief note in the examples/notes clarifying the recommended pattern for read-only class-level values.
Log in (anonymous is fine) to add a comment.