On Wednesday 18 April 2007 15:59, Alek Storm wrote:
> Without :vtable, :method adds a method to the class. With :vtable,
> :method doesn't add a method to the class - it makes the sub visible.
> Two completely different things.
I'd like to see some example code; this does not match my experience.
.sub 'main' :main
.local pmc my_int_class
my_int_class = subclass 'Integer', 'MyInt'
.local int int_type
int_type = find_type 'MyInt'
.local pmc my_int
my_int = new int_type
my_int = 100
my_int.'set_integer_native'( 200 )
my_int = 1.01
my_int.'set_number_native'( 2.02 )
my_int = 'hello'
my_int.'set_string_native'( 'world' )
.end
.namespace [ 'MyInt' ]
.sub 'set_number_native' :method
.param num value
print "Setting new value: "
print value
print "\n"
.end
.sub 'set_string_native' :vtable
.param string value
print "Setting new value: "
print value
print "\n"
.end
.sub 'set_integer_native' :vtable :method
.param int value
print "Setting new value: "
print value
print "\n"
.end
-- c