package require Tcl 8.5

load [file join [file dirname [info script]] structure.so]

set m [structure]
proc modulefunc {name module argpat body} {
 $module $name [list $argpat "set module $module; $body"]
}

modulefunc init $m {} {
  puts INIT
 # More code...
}

modulefunc widget $m {w args} {
 apply [$module widget.instance] $w {expand}$args
}

modulefunc widget.instance $m {w args} {
 puts INSTANCE:$args
}

apply [$m init]
apply [$m widget] .a -text ABC
