[Xotcl] xotcl::nonposArgs

Stefan Sobernig stefan.sobernig at wu.ac.at
Wed Jul 15 13:58:16 CEST 2015


Hi Michael!

>> What is the correct way to port this to XOTcl 2.0?

This is most likely not an authoritative answer, I don't have the time 
right now to think this through properly. The following should get you 
going for the time being:

if {[info command ::nx::methodParameterSlot] ne ""} {
     ::nx::methodParameterSlot object method type=sourced_guid {name 
value args} {
	if {![::nsf::is object $value] || [xotcl::Object info instances 
-closure $value] eq ""} {
	    error "'$value' is not an XOTcl object"
	}
	if {![$value istype ::foo::bar::SourcedGuid]} {
	    error "'$value' is not of type SourcedGuid but [$value info class]"
	}
     }
}

If you plan to co-maintain two code bases (one compatible with 1.6 and 
the other for 2+), then you might want to consider factoring out the 
value checker into a plain Tcl proc and forward/alias to this proc 
conditionally from ::xotcl::nonposArgs and ::nx::methodParameterSlot, 
respectively.

I leave this as an exercise to you ;)

Let me know whether the above works for you for the time being.

Cheers,
Stefan

P.S.: I suggest using "return -code error" in your value checker to skip 
one level on the callstack trace reported to the developer, to hide the 
details of the value checker in the reported trace.


More information about the Xotcl mailing list