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

[Xotcl] Can't call protected class method from instances

From: Arthur Schreiber <schreiber.arthur_at_googlemail.com>
Date: Fri, 10 Feb 2012 11:45:08 +0100

Hello Gustaf,

Is not being able to call protected class methods from instances intended
behaviour?

Here is a very simple test case:

package require nx

nx::Class create Greeter {
    :class protected method say_hi {} {
        puts "Hello!"
    }

    :public method say_hi {} {
        [:info class] say_hi
    }
}

[Greeter new] say_hi

Also, protected methods can not be called from instances of the same class,
e.g.:

package require nx

nx::Class create Greeter {
    :public method say_hi { other_greeter } {
        $other_greeter protected_say_hi
    }

    :protected method protected_say_hi { } {
        puts "Hello!"
    }
}

set g1 [Greeter new]

[Greeter new] say_hi $g1

Kind Regards,
Arthur