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

Re: [Xotcl] error whilst following tutorial

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Mon, 22 Dec 2008 22:58:30 +0100

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