[Xotcl] Static member functions?
Neophytos Demetriou
k2pts at cytanet.com.cy
Wed Apr 16 08:39:06 CEST 2003
Hi Michael (of nstcl fame right?),
it's glad to see you in this list. I'm sure Gustaf or Uwe will have a
better response for you but here's what I do:
AFAICS, static member variables are not supported as a language
construct but you can either have a variable in the "Chapters" class, e.g.
Class Chapters
Chapters set current_chapter 12345
which can be fetched using [Chapters set current_chapter] from any other
object or class or from an instance you can get/set the value as follows:
Chapters aChapter
[aChapter info class] set current_chapter 4567
puts [[aChapter info class] set current_chapter]
Now, suppose you have a Class instproc say printCurrentChapter:
Chapters instproc printCurrentChapter {} {
puts [[my info class] set current_chapter]
}
aChapter printCurrentChapter
I hope that helps.
Best wishes,
Neophytos
Michael A. Cleverly wrote:
>(Disclaimer: I'm quite new to XOTcl & I have read the tutorial a couple
>times but maybe not enough. :-)
>
>What's the XOTcl idiom/way for a static member variable (what snit, the
>only other OO Tcl package/extension I've used, would call a "type
>variable")?
>
>Contrived example: if I had a "Chapters" class, I'd like to have a single
>variable, accessible by all instances of the class, that kept track of the
>"current" chapter. Suggestions?
>
>Michael
>
>_______________________________________________
>Xotcl mailing list - Xotcl at alice.wu-wien.ac.at
>http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
>
>
>
>
>
More information about the Xotcl
mailing list