[Xotcl] error whilst following tutorial

Gustaf Neumann neumann at wu-wien.ac.at
Mon Dec 22 22:58:30 CET 2008


Bernard Devlin schrieb:
>
> However, following the main XOTcl tutorial 
> (http://media.wu-wien.ac.at/doc/tutorial.html) in the IDE, I've got a 
> problem.  After running 'do it' on each stage of the tutorial, when I 
> get to this line:
>
> set fb [bayernMunich newPlayer -name "Franz Beckenbauer" \
>   -playerRole PLAYER]
>
> I get an error.  Here's the stack trace:
>
> ::bayernMunich::__#WZ: unable to dispatch method 'name' during ...
>

Dear Bernard,

a first challenge is to interprete tcl's error messages. In the example you
gave, it says, that the player that you create (object  
"::bayernMunich::__#WZ")
does not have a method called "name". In the example in the tutorial,
"name" is an attribute defined by ClubMember. XOTcl calls publically
accessible attributes "parameters" and creates for those accessor
methods.

Given the definitions

  Class ClubMember -parameter {{name ""}}
  Class Player -superclass ClubMember -parameter {{playerRole NONE}}

one can create a Player with the name "Kaiser Franz" with the command

   Player create p1 -name "Kaiser Franz"

Note that all tokens starting with a "-" are actually methods,
which are called during initialization (after allocation of the object,
but before init is called) with the provided arguments .
 
So, in your case, i guess, you have either omitted the name-definition
on ClubMember, or omitted the "superclass" on Player.

best regards
-gustaf neumann



More information about the Xotcl mailing list