#!/usr/bin/env tclsh9

oo::class create V {
    method valid_int {i} {
        if {![string is integer -strict $i]} {
            throw NOT_AN_INT "must be an int not \"$i\""
        }
        return $i
    }
    unexport valid_int
}

oo::configurable create Q {
    mixin V
    variable x y

    constructor args {
        my configure -x 0 -y 0 {*}$args
    }

    property x -set { set x [my valid_int $value] }
    property y -set { set y [my valid_int $value] }
}

puts "Q"
set q1 [Q new]
puts "q1 x=[$q1 configure -x] y=[$q1 configure -y]"
$q1 configure -x 5
puts "q1 [$q1 configure]"
try {$q1 configure -x "invalid"} trap {} err { puts $err }
set q2 [Q new -x 0 -y -8]
puts "q2 [$q2 configure]"
$q2 configure -x 17
puts "q2 [$q2 configure]"
puts "q1 [$q1 configure]"
try {$q1 valid_int 5} trap {} err { puts $err }
