Introduction

... general text, maybe partly from slides/paper ....

Supporting XOTcl 1 in XOTcl 2

... multiple object systems ....

::xotcl::use xotcl1

::xotcl::use xotcl2

describe, what ::xotcl::use does

XOTcl 1 Idioms in XOTcl 2

Defining Objects and Classes

XOTcl 1XOTcl 2
Class ClassName Class create ClassName
Object ObjectName Object create ObjectName
::xotcl::Class ClassName ::xotcl2::Class create ClassName
::xotcl::Object ObjectName ::xotcl2::Object create ObjectName

Defining Methods

XOTcl 1XOTcl 2
Class C
C instproc foo args {...}
C proc bar args {...}
Class create C {
  .method foo args {...}
  .object method bar args {...}
}

Class create C
C method foo args {...}
C object method bar args {...}
Object o
o set x 1
o proc foo args {...}
Object create o {
  set .x 1
  .method foo args {...}
}

Object create o
# recommendation missing: alternatives:
#    o eval {set .x 1}
#    ::xotcl::setinstvar o x 1
o method foo args {...}

Invoking Methods

XOTcl 1XOTcl 2
Class C
C instproc foo args {...}
C instproc bar args {
  my foo 1 2 3 ;# invoke own method
  o baz        ;# invoke others method
}
Object o
o proc baz {} {...}
Class create C {
  .method foo args {...}
  .method bar args {
     .foo 1 2 3 ;# invoke own method
     o baz      ;# invoke others method
  }
}
Object create o {
  .method baz {} {...}
}

Accessing Instance Variables from Method Bodies

XOTcl 1XOTcl 2
my set varname value set .varname value
set newVar [my set otherVar] set newVar [set .otherVar]

set newVar ${.otherVar}
my instvar newVar
set newVar value
set .newVar value
my exists varname info .varname

Accessing Instance Variables of other Objects

XOTcl 1XOTcl 2
someObject set varname value ...
set newVar [someObject set otherVar] set newVar [...]
someObject instvar newVar
set newVar value
::xotcl::importvar someObject newVar
set newVar value
someObject exists varname ... do we have to keep exists for this reason? ...

Object Parameters

Method Parameters

Introspection

Predefined Methods

Dispatch, Aliases, etc.

Method Protection


Last modified: Sat Jan 2 15:04:41 CET 2010