|
2026-06-04
| ||
| 12:41 | • Closed ticket [f8a20dff9c]: Doc: description of command "variable" inc... artifact: c6d3297683 user: oehhar | |
| 12:30 | • Ticket [f8a20dff9c]: 3 changes artifact: 5aad166024 user: sbron | |
| 05:25 | • Ticket [f8a20dff9c]: 3 changes artifact: 4a91d05e4b user: apnadkarni | |
|
2026-06-03
| ||
| 13:54 | • Ticket [f8a20dff9c]: 3 changes artifact: ae9d0a3b94 user: oehhar | |
| 13:51 | • New ticket [f8a20dff9c]. artifact: 5e0d91d4b8 user: oehhar | |
Doc: description of command "variable" incomplete
variable name variable ?name value...?
I don't know what this means.
The described form is:
variable name ?value?
Unfortunately, the command accepts 0 to infinite arguments. Only 1 or 2 arguments do something:
% namespace eval test {variable v1 c1 c2 c3}
% set test::v1
c1
What is this for:
% namespace eval test {variable}
This is probably due to the fact, that in OO context, the command has a totally different syntax (Ashoks book, page 394):
variable ?SLOTOPERATION? ?VARNAME ...?
The same command "variable v1 c1" means different things:
- in namespaces, a namespace variable v1 is set to c1
- in OO, the variables v1 and c1 are defined as class variables.
Great !
I would love, if the command:
- would give a propper error message, if used in the different contextes.
- the documentation would document all this strange stuff.
Sorry for my OO unskill level, it is all strange.
Take care, Harald
The use of variable within a class definition (oo::define) has different syntax and is described in the oo::define manpage. (It is also not a "class variable" as that term has a different meaning.)
I agree it is confusing to have a different syntax for commands of the same name and with similar, but not identical function, even though in different scopes but not sure much can be done about it now.
I frequently use the variable command with more than 2 arguments. I'm not sure why you claim that "[o]nly 1 or 2 arguments do something". Here's proof to the contrary:
% namespace eval test {variable v1 c1 v2 c2}
% set test::v1
c1
% set test::v2
c2
A, thanks. That makes sense.
That is what the syntax in the man page eans:
variable ?name value...?
arbitrary number of variable name and value.
If that is the interpretation, why does this not raise an error:
namespace eval test {variable v1 c1 v2}
This would be the syntax:
variable ?name value...? ?name?
Anyway, thanks for all, noise for nothing but a big dump stupid user...
Sorry, bug closed.
THanks, Harald