View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] Static member functions?

From: Neophytos Demetriou <>
Date: Wed, 16 Apr 2003 09:39:06 +0300

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,

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
>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?
>Xotcl mailing list -