Index: TODO =================================================================== diff -u -rc7b94af116f0a5850e91d8422594a1fd8cee1fba -r65f8883a4596ea98365b7de1652700e3ac7394cc --- TODO (.../TODO) (revision c7b94af116f0a5850e91d8422594a1fd8cee1fba) +++ TODO (.../TODO) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -2431,7 +2431,7 @@ - added "... info method exists ...." - updated migration guide -- changed named of method handling commands in nsf: +- changed names of method handling commands in nsf: ::nsf::methodproperty => ::nsf::method::property ::nsf::method => ::nsf::method::create ::nsf::methoddelete => ::nsf::method::delete @@ -2451,7 +2451,12 @@ - improved documentation - removed isInitString() +- changed names of var handling commands in nsf: + ::nsf::existsvar => ::nsf::var::exists + ::nsf::importvar => ::nsf::var::import + ::nsf::setvar => ::nsf::var::set + TODO: - fix misleading error message: Index: generic/gentclAPI.decls =================================================================== diff -u -re3a84e351aaf79c02a63cc0741dde7b9bd550849 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision e3a84e351aaf79c02a63cc0741dde7b9bd550849) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -40,17 +40,8 @@ nsfCmd colon NsfColonCmd { {-argName "args" -type allargs} } -nsfCmd existsvar NsfExistsVarCmd { - {-argName "object" -required 1 -type object} - {-argName "varName" -required 1} -} nsfCmd finalize NsfFinalizeObjCmd { } - -nsfCmd importvar NsfImportvarCmd { - {-argName "object" -required 1 -type object} - {-argName "args" -type args} -} nsfCmd interp NsfInterpObjCmd { {-argName "name" -required 1} {-argName "args" -type allargs} @@ -147,18 +138,27 @@ {-argName "relationtype" -required 1 -type "object-mixin|class-mixin|object-filter|class-filter|class|superclass|rootclass"} {-argName "value" -required 0 -type tclobj} } + nsfCmd current NsfCurrentCmd { {-argName "currentoption" -required 0 -type "proc|method|methodpath|object|class|activelevel|args|activemixin|calledproc|calledmethod|calledclass|callingproc|callingmethod|callingclass|callinglevel|callingobject|filterreg|isnextcall|next"} } nsfCmd self NsfSelfCmd { } -nsfCmd setvar NsfSetVarCmd { + +nsfCmd "var::exists" NsfExistsVarCmd { {-argName "object" -required 1 -type object} + {-argName "varName" -required 1} +} +nsfCmd "var::import" NsfImportvarCmd { + {-argName "object" -required 1 -type object} + {-argName "args" -type args} +} +nsfCmd "var::set" NsfSetVarCmd { + {-argName "object" -required 1 -type object} {-argName "varName" -required 1 -type tclobj} {-argName "value" -required 0 -type tclobj} } - # # object methods # Index: generic/nsf.c =================================================================== diff -u -rc09fd1356ee0d275a8e0fa921744f052493f1a79 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- generic/nsf.c (.../nsf.c) (revision c09fd1356ee0d275a8e0fa921744f052493f1a79) +++ generic/nsf.c (.../nsf.c) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -14541,7 +14541,7 @@ } /* -nsfCmd alias NsfAliasCmd { +nsfCmd method::alias NsfAliasCmd { {-argName "object" -type object} {-argName "-per-object"} {-argName "methodName"} @@ -14710,7 +14710,7 @@ } /* -nsfCmd assertion NsfAssertionCmd { +nsfCmd method::assertion NsfAssertionCmd { {-argName "object" -type object} {-argName "assertionsubcmd" -required 1 -type "check|object-invar|class-invar"} {-argName "arg" -required 0 -type tclobj} @@ -15117,7 +15117,7 @@ } /* -nsfCmd existsvar NsfExistsVarCmd { +nsfCmd var::exists NsfExistsVarCmd { {-argName "object" -required 1 -type object} {-argName "varname" -required 1} } @@ -15174,7 +15174,7 @@ } /* -nsfCmd forward NsfForwardCmd { +nsfCmd method::forward NsfForwardCmd { {-argName "object" -required 1 -type object} {-argName "-per-object"} {-argName "method" -required 1 -type tclobj} @@ -15230,7 +15230,7 @@ } /* -nsfCmd importvar NsfImportvarCmd { +nsfCmd var::import NsfImportvarCmd { {-argName "object" -type object} {-argName "args" -type args} } @@ -15369,7 +15369,7 @@ /* -nsfCmd method NsfMethodCmd { +nsfCmd method::create NsfMethodCmd { {-argName "object" -required 1 -type object} {-argName "-inner-namespace"} {-argName "-per-object"} @@ -15398,7 +15398,7 @@ } /* -nsfCmd methodproperty NsfMethodPropertyCmd { +nsfCmd ::method::property NsfMethodPropertyCmd { {-argName "object" -required 1 -type object} {-argName "-per-object"} {-argName "methodName" -required 1 -type tclobj} @@ -16384,7 +16384,7 @@ } /* -nsfCmd setvar NsfSetVarCmd { +nsfCmd var::set NsfSetVarCmd { {-argName "object" -required 1 -type object} {-argName "varname" -required 1 -type tclobj} {-argName "value" -required 0 -type tclobj} @@ -16401,7 +16401,7 @@ } /* -nsfCmd setter NsfSetterCmd { +nsfCmd method::setter NsfSetterCmd { {-argName "object" -required 1 -type object} {-argName "-per-object"} {-argName "parameter" -type tclobj} Index: generic/tclAPI.h =================================================================== diff -u -re3a84e351aaf79c02a63cc0741dde7b9bd550849 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- generic/tclAPI.h (.../tclAPI.h) (revision e3a84e351aaf79c02a63cc0741dde7b9bd550849) +++ generic/tclAPI.h (.../tclAPI.h) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -2209,7 +2209,7 @@ {"command", NSF_ARG_REQUIRED, 0, ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"args", 0, 0, ConvertToNothing, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, -{"::nsf::existsvar", NsfExistsVarCmdStub, 2, { +{"::nsf::var::exists", NsfExistsVarCmdStub, 2, { {"object", NSF_ARG_REQUIRED, 0, ConvertToObject, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"varName", NSF_ARG_REQUIRED, 0, ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, @@ -2229,7 +2229,7 @@ {"target", 0, 0, ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"args", 0, 0, ConvertToNothing, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, -{"::nsf::importvar", NsfImportvarCmdStub, 2, { +{"::nsf::var::import", NsfImportvarCmdStub, 2, { {"object", NSF_ARG_REQUIRED, 0, ConvertToObject, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"args", 0, 0, ConvertToNothing, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, @@ -2304,7 +2304,7 @@ {"::nsf::self", NsfSelfCmdStub, 0, { {NULL, 0, 0, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, -{"::nsf::setvar", NsfSetVarCmdStub, 3, { +{"::nsf::var::set", NsfSetVarCmdStub, 3, { {"object", NSF_ARG_REQUIRED, 0, ConvertToObject, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"varName", NSF_ARG_REQUIRED, 0, ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"value", 0, 0, ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} Index: library/lib/doc-tools.tcl =================================================================== diff -u -r440400dcb01fed8b18c4a2d98e4eca5dbaf309e4 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- library/lib/doc-tools.tcl (.../doc-tools.tcl) (revision 440400dcb01fed8b18c4a2d98e4eca5dbaf309e4) +++ library/lib/doc-tools.tcl (.../doc-tools.tcl) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -498,7 +498,7 @@ :public method get {obj prop} { set def [expr {[info exists :default]?${:default}:0}] if {[$obj eval [list set :$prop]] == $def} { - return [::nsf::setvar $obj $prop [expr {!$def}]] + return [::nsf::var::set $obj $prop [expr {!$def}]] } return [next] } @@ -2667,7 +2667,7 @@ if {[info commands "::nx::Class"] ne ""} { if {[::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::Slot]} { dict set bundle objtype slot - dict set bundle incremental [expr {[::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::RelationSlot] || ([::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::Attribute] && [::nsf::existsvar $obj incremental] && [::nsf::setvar $obj incremental])}] + dict set bundle incremental [expr {[::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::RelationSlot] || ([::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::Attribute] && [::nsf::var::exists $obj incremental] && [::nsf::var::set $obj incremental])}] } if {[::nsf::dispatch $obj ::nsf::methods::object::info::hastype ::nx::EnsembleObject]} { dict set bundle objtype ensemble @@ -2679,7 +2679,7 @@ ->source [file normalize [info script]] \ ->nsexported [::nx::doc::is_exported $obj] \ ->bundle $bundle \ - {*}[expr {[::nsf::existsvar $obj __initcmd] && [::nsf::setvar $obj __initcmd] ne ""?[list ->docstring [::nsf::setvar $obj __initcmd]]:[list]}] + {*}[expr {[::nsf::var::exists $obj __initcmd] && [::nsf::var::set $obj __initcmd] ne ""?[list ->docstring [::nsf::var::set $obj __initcmd]]:[list]}] return $obj } ::nsf::mixin $rootmclass ${::nx::doc::rootns}::__Tracer @@ -2715,7 +2715,7 @@ set handle [::nsf::dispatch $obj \ ::nsf::methods::${scope}::info::method \ handle $leg] - if {![::nsf::existsvar [::nsf::current class] handles] || ![[::nsf::current class] eval [concat dict exists \${:handles} $handle]]} { + if {![::nsf::var::exists [::nsf::current class] handles] || ![[::nsf::current class] eval [concat dict exists \${:handles} $handle]]} { dict set bundle handle $handle dict set bundle handleinfo [::nx::doc::handleinfo $handle] dict set bundle type [::nsf::dispatch ${::nx::doc::rootns}::__Tracer ::nsf::methods::${scope}::info::method type $handle] @@ -2906,7 +2906,7 @@ ->cmdtype @class \ ->source [file normalize [info script]] \ ->nsexported [::nx::doc::is_exported $r] \ - {*}[expr {[::nsf::existsvar $r __initcmd] && [::nsf::setvar $obj __initcmd] ne ""?[list ->docstring [::nsf::setvar $r __initcmd]]:[list]}] + {*}[expr {[::nsf::var::exists $r __initcmd] && [::nsf::var::set $obj __initcmd] ne ""?[list ->docstring [::nsf::var::set $r __initcmd]]:[list]}] } } Index: library/nx/nx.tcl =================================================================== diff -u -r596677fb3ed1e15dc62a04789781347fb3dbc369 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- library/nx/nx.tcl (.../nx.tcl) (revision 596677fb3ed1e15dc62a04789781347fb3dbc369) +++ library/nx/nx.tcl (.../nx.tcl) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -707,7 +707,7 @@ #puts stderr "::nx::BootStrapAttributeSlot create $slotObj" ::nx::BootStrapAttributeSlot create $slotObj if {[info exists default]} { - ::nsf::setvar $slotObj default $default + ::nsf::var::set $slotObj default $default unset default } ::nsf::method::setter $class $att @@ -723,14 +723,14 @@ # checking subclasses is not required during bootstrap foreach i [::nsf::dispatch $class ::nsf::methods::class::info::instances] { - if {![::nsf::existsvar $i $att]} { + if {![::nsf::var::exists $i $att]} { if {[string match {*\[*\]*} $default]} { set value [::nsf::dispatch $i -frame object ::eval subst $default] } else { set value $default } - ::nsf::setvar $i $att $value - #puts stderr "::nsf::setvar $i $att $value (second round)" + ::nsf::var::set $i $att $value + #puts stderr "::nsf::var::set $i $att $value (second round)" } } unset default @@ -1118,8 +1118,8 @@ ::nx::Attribute protected method checkInstVar {} { if {${:per-object} && [info exists :default] } { - if {![::nsf::existsvar ${:domain} ${:name}]} { - ::nsf::setvar ${:domain} ${:name} ${:default} + if {![::nsf::var::exists ${:domain} ${:name}]} { + ::nsf::var::set ${:domain} ${:name} ${:default} } } } @@ -1215,7 +1215,7 @@ } set options [:getParameterOptions -withMultiplicity true] lappend options slot=[::nsf::self] - set body {::nsf::setvar $obj $var $value} + set body {::nsf::var::set $obj $var $value} if {[:info lookup method assign] eq "::nsf::classes::nx::Attribute::assign"} { puts stderr ":public method assign [list obj var [:namedParameterSpec -prefix {} value $options]] $body" @@ -1262,25 +1262,25 @@ # # implementation of forwarder operations: assign get add delete # - ::nsf::method::alias Attribute get ::nsf::setvar - ::nsf::method::alias Attribute assign ::nsf::setvar + ::nsf::method::alias Attribute get ::nsf::var::set + ::nsf::method::alias Attribute assign ::nsf::var::set Attribute public method add {obj prop value {pos 0}} { if {![:isMultivalued]} { puts stderr "... vars [[self] info vars] // [[self] eval {set :multiplicity}]" error "Property $prop of [set :domain] ist not multivalued" } - if {[::nsf::existsvar $obj $prop]} { - ::nsf::setvar $obj $prop [linsert [::nsf::setvar $obj $prop] $pos $value] + if {[::nsf::var::exists $obj $prop]} { + ::nsf::var::set $obj $prop [linsert [::nsf::var::set $obj $prop] $pos $value] } else { - ::nsf::setvar $obj $prop [list $value] + ::nsf::var::set $obj $prop [list $value] } } Attribute public method delete {-nocomplain:switch obj prop value} { - set old [::nsf::setvar $obj $prop] + set old [::nsf::var::set $obj $prop] set p [lsearch -glob $old $value] - if {$p>-1} {::nsf::setvar $obj $prop [lreplace $old $p $p]} else { + if {$p>-1} {::nsf::var::set $obj $prop [lreplace $old $p $p]} else { error "$value is not a $prop of $obj (valid are: $old)" } } @@ -1292,15 +1292,15 @@ #puts "GETVAR [::nsf::current method] obj=$obj cmd=$cmd, var=$var, op=$op" ::nsf::dispatch $obj -frame object \ ::trace remove variable $var $op [list [::nsf::self] [::nsf::current method] $obj $cmd] - ::nsf::setvar $obj $var [$obj eval $cmd] + ::nsf::var::set $obj $var [$obj eval $cmd] } Attribute method __value_from_cmd {obj cmd var sub op} { #puts "GETVAR [::nsf::current method] obj=$obj cmd=$cmd, var=$var, op=$op" - ::nsf::setvar $obj $var [$obj eval $cmd] + ::nsf::var::set $obj $var [$obj eval $cmd] } Attribute method __value_changed_cmd {obj cmd var sub op} { # puts stderr "**************************" - # puts "valuechanged obj=$obj cmd=$cmd, var=$var, op=$op, ...\n$obj exists $var -> [::nsf::setvar $obj $var]" + # puts "valuechanged obj=$obj cmd=$cmd, var=$var, op=$op, ...\n$obj exists $var -> [::nsf::var::set $obj $var]" eval $cmd } @@ -1339,13 +1339,13 @@ ::nx::MetaSlot createFromParameterSpec [::nsf::self] {*}$arg } set slot [::nx::slotObj [::nsf::self]] - ::nsf::setvar $slot __parameter $arglist + ::nsf::var::set $slot __parameter $arglist } Class method "info attributes" {} { set slot [::nx::slotObj [::nsf::self]] - if {[::nsf::existsvar $slot __parameter]} { - return [::nsf::setvar $slot __parameter] + if {[::nsf::var::exists $slot __parameter]} { + return [::nsf::var::set $slot __parameter] } return "" } @@ -1381,7 +1381,7 @@ :protected method init {} { :public method new {-childof args} { - ::nsf::importvar [::nsf::current class] {container object} withclass + ::nsf::var::import [::nsf::current class] {container object} withclass if {![::nsf::isobject $object]} { $withclass create $object } @@ -1644,9 +1644,9 @@ # framework is faster than namespace-ensembles. # Object create ::nx::var { - :public alias exists ::nsf::existsvar - :public alias import ::nsf::importvar - :public alias set ::nsf::setvar + :public alias exists ::nsf::var::exists + :public alias import ::nsf::var::import + :public alias set ::nsf::var::set } #interp alias {} ::nx::self {} ::nsf::self Index: library/serialize/serializer.tcl =================================================================== diff -u -re3a84e351aaf79c02a63cc0741dde7b9bd550849 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- library/serialize/serializer.tcl (.../serializer.tcl) (revision e3a84e351aaf79c02a63cc0741dde7b9bd550849) +++ library/serialize/serializer.tcl (.../serializer.tcl) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -180,7 +180,7 @@ # we export the object tree. set oo $o while {1} { - if {[::nsf::existsvar [::nsf::current class] exportObjects($o)]} { + if {[::nsf::var::exists [::nsf::current class] exportObjects($o)]} { return 1 } # we do this for object trees without object-less namespaces @@ -585,7 +585,7 @@ if {[$o eval [list ::array exists :$v]]} { lappend setcmd [list array set :$v [$o eval [list array get :$v]]] } else { - lappend setcmd [list set :$v [::nsf::setvar $o $v]] + lappend setcmd [list set :$v [::nsf::var::set $o $v]] } } } Index: library/xotcl/tests/slottest.xotcl =================================================================== diff -u -re3a84e351aaf79c02a63cc0741dde7b9bd550849 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision e3a84e351aaf79c02a63cc0741dde7b9bd550849) +++ library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -204,7 +204,7 @@ o1 set z 100 #o1 forward z o1 [list %argclindex [list set set]] %proc #o1 proc get name {my set $name} -o1 forward get -earlybinding ::nsf::setvar %self %1 +o1 forward get -earlybinding ::nsf::var::set %self %1 ? {o1 info forward} get ? {o1 get z 101} 101 ? {o1 get z} "101" @@ -213,7 +213,7 @@ ? {o1 get z 124} 124 "set value via new parametercmd get" -o1 forward zz -earlybinding ::nsf::setvar %self %proc +o1 forward zz -earlybinding ::nsf::var::set %self %proc ? {o1 zz 123} 123 ? {o1 zz} 123 @@ -583,7 +583,7 @@ ? {o1 myf 100} 200 o1 set x 42 -o1 forward x -earlybinding ::nsf::setvar %self %proc +o1 forward x -earlybinding ::nsf::var::set %self %proc ? [list o1 x] 42 ? [list o1 x 41] 41 ? {o1 x} "get parametercmd via forward (earlybinding)" @@ -622,7 +622,7 @@ P create p2 -age 345 -s 567 ? {p2 age} "parametercmd read" -? {::nsf::setvar p2 age} "via setinstvar" +? {::nsf::var::set p2 age} "via setinstvar" ? {p2 s} "parameter read with setter" Index: tests/alias.test =================================================================== diff -u -re3a84e351aaf79c02a63cc0741dde7b9bd550849 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- tests/alias.test (.../alias.test) (revision e3a84e351aaf79c02a63cc0741dde7b9bd550849) +++ tests/alias.test (.../alias.test) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -9,7 +9,7 @@ # The system methods of nx::Attribute are either alias or forwarders ? {lsort [::nx::Attribute info methods -methodtype alias]} {assign get} ? {::nx::Attribute info method definition get} \ - "::nx::Attribute public alias get ::nsf::setvar" + "::nx::Attribute public alias get ::nsf::var::set" # define an alias and retrieve its definition set cmd "::nx::Object public alias set ::set" Index: tests/doc.test =================================================================== diff -u -r596677fb3ed1e15dc62a04789781347fb3dbc369 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- tests/doc.test (.../doc.test) (revision 596677fb3ed1e15dc62a04789781347fb3dbc369) +++ tests/doc.test (.../doc.test) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -1091,18 +1091,18 @@ ::nsf::assertion ::nsf::createobjectsystem ::nsf::dispatch - ::nsf::existsvar + ::nsf::var::exists ::nsf::exithandler ::nsf::forward - ::nsf::importvar + ::nsf::var::import ::nsf::isobject ::nsf::method ::nsf::method::property ::nsf::method::provide ::nsf::qualify ::nsf::method::require ::nsf::setter - ::nsf::setvar + ::nsf::var::set } set project [processor process \ Index: tests/parameters.test =================================================================== diff -u -r5039877970c5ab19bc80586e0d49bfd715873e98 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- tests/parameters.test (.../parameters.test) (revision 5039877970c5ab19bc80586e0d49bfd715873e98) +++ tests/parameters.test (.../parameters.test) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -1171,7 +1171,7 @@ ::nx::Object create o { :attribute a {set :defaultcmd { set _ 4 } } :attribute b {set :valuecmd { set _ 44 } } - :attribute c {set :valuechangedcmd { ::nsf::setvar $obj $var 999 }} + :attribute c {set :valuechangedcmd { ::nsf::var::set $obj $var 999 }} } ? {o a} 4 @@ -1187,7 +1187,7 @@ ::nx::Class create C { :attribute a {set :defaultcmd { set _ 4 } } :attribute b {set :valuecmd { set _ 44 } } - :attribute c {set :valuechangedcmd { ::nsf::setvar $obj $var 999 }} + :attribute c {set :valuechangedcmd { ::nsf::var::set $obj $var 999 }} :create c1 } ? {c1 a} 4 Index: tests/var-access.test =================================================================== diff -u -r84c5ee62a46e8fab7b9cc481c87290d387baced9 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- tests/var-access.test (.../var-access.test) (revision 84c5ee62a46e8fab7b9cc481c87290d387baced9) +++ tests/var-access.test (.../var-access.test) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -5,16 +5,16 @@ namespace eval ::nx::var1 { namespace ensemble create -map { - exists ::nsf::existsvar - import ::nsf::importvar - set ::nsf::setvar + exists ::nsf::var::exists + import ::nsf::var::import + set ::nsf::var::set } } ::nx::Object create ::nx::var2 { - :alias exists ::nsf::existsvar - :alias import ::nsf::importvar - :alias set ::nsf::setvar + :alias exists ::nsf::var::exists + :alias import ::nsf::var::import + :alias set ::nsf::var::set } Test parameter count 10000 @@ -31,7 +31,7 @@ o eval {incr :x} } :method foo2 {} { - ::nsf::importvar o x + ::nsf::var::import o x incr x } :method foo3 {} { @@ -44,9 +44,9 @@ } } - ? {::nsf::setvar o x} 1 - ? {::nsf::existsvar o x} 1 - ? {::nsf::existsvar o y} 0 + ? {::nsf::var::set o x} 1 + ? {::nsf::var::exists o x} 1 + ? {::nsf::var::exists o y} 0 ? {::nx::var1 set o x} 1 ? {::nx::var1 exists o x} 1 @@ -59,16 +59,16 @@ ? {p foo0} 2 ? {p foo1} 2 - ? {::nsf::setvar o x} 10002 + ? {::nsf::var::set o x} 10002 ? {p foo2} 10003 - ? {::nsf::setvar o x} 20003 + ? {::nsf::var::set o x} 20003 ? {p foo3} 20004 - ? {::nsf::setvar o x} 30004 + ? {::nsf::var::set o x} 30004 ? {p foo4} 30005 - ? {::nsf::setvar o x} 40005 + ? {::nsf::var::set o x} 40005 } puts stderr =====END Index: tests/varresolution.test =================================================================== diff -u -re3a84e351aaf79c02a63cc0741dde7b9bd550849 -r65f8883a4596ea98365b7de1652700e3ac7394cc --- tests/varresolution.test (.../varresolution.test) (revision e3a84e351aaf79c02a63cc0741dde7b9bd550849) +++ tests/varresolution.test (.../varresolution.test) (revision 65f8883a4596ea98365b7de1652700e3ac7394cc) @@ -50,7 +50,7 @@ # vartables on the stack :require namespace global g - ::nsf::importvar o2 i + ::nsf::var::import o2 i set x 1 set :y 2 set ::z 3 @@ -59,28 +59,28 @@ set :a(:b) 1 set :a(::c) 1 } -? {::nsf::importvar o2 j} \ +? {::nsf::var::import o2 j} \ "importvar cannot import variable 'j' into method scope; not called from a method frame" -o method foo {} {::nsf::importvar [current] :a} +o method foo {} {::nsf::var::import [current] :a} ? {o foo} "variable name \":a\" must not contain namespace separator or colon prefix" -o method foo {} {::nsf::importvar [current] ::a} +o method foo {} {::nsf::var::import [current] ::a} ? {o foo} "variable name \"::a\" must not contain namespace separator or colon prefix" -o method foo {} {::nsf::importvar [current] a(:b)} +o method foo {} {::nsf::var::import [current] a(:b)} ? {o foo} "can't make instance variable a(:b) on ::o: Variable cannot be an element in an array; use e.g. an alias." -o method foo {} {::nsf::importvar [current] {a(:b) ab}} +o method foo {} {::nsf::var::import [current] {a(:b) ab}} ? {o foo} "" -o method foo {} {::nsf::existsvar [current] ::a} +o method foo {} {::nsf::var::exists [current] ::a} ? {o foo} "variable name \"::a\" must not contain namespace separator or colon prefix" -o method foo {} {::nsf::existsvar [current] a(:b)} +o method foo {} {::nsf::var::exists [current] a(:b)} ? {o foo} 1 -o method foo {} {::nsf::existsvar [current] a(::c)} +o method foo {} {::nsf::var::exists [current] a(::c)} ? {o foo} 1 set ::o::Y 5 @@ -108,7 +108,7 @@ Object create o { :require namespace global g - ::nsf::importvar o2 i + ::nsf::var::import o2 i set x 1 set :y 2 set ::z 3 @@ -172,7 +172,7 @@ ? {::o set x} 3 ? {namespace eval ::o {info exists x}} 1 ? {::o unset x} "" -? {::nsf::existsvar o x} 0 +? {::nsf::var::exists o x} 0 ? {o eval {info exists :x}} 0 ? {info vars ::x} "" ? {namespace eval ::o {info exists x}} 0 @@ -867,17 +867,17 @@ set script { # early probing: reflects the compiled-only, unexecuted state set _ [join [list {*}[lsort [info vars :*]] [info locals :*] \ - [info exists :u] [::nsf::existsvar [::nsf::current] u] \ - [info exists :v] [::nsf::existsvar [::nsf::current] v] \ - [info exists :x] [::nsf::existsvar [::nsf::current] x]] "-"] + [info exists :u] [::nsf::var::exists [::nsf::current] u] \ + [info exists :v] [::nsf::var::exists [::nsf::current] v] \ + [info exists :x] [::nsf::var::exists [::nsf::current] x]] "-"] catch {set :u} set :v 1 unset :x # late probing: reflects the (ideally) compiled, *executed* state append _ | [join [list {*}[lsort [info vars :*]] [info locals :*] \ - [info exists :u] [::nsf::existsvar [::nsf::current] u] \ - [info exists :v] [::nsf::existsvar [::nsf::current] v] \ - [info exists :x] [::nsf::existsvar [::nsf::current] x]] "-"] + [info exists :u] [::nsf::var::exists [::nsf::current] u] \ + [info exists :v] [::nsf::var::exists [::nsf::current] v] \ + [info exists :x] [::nsf::var::exists [::nsf::current] x]] "-"] return $_ } @@ -916,13 +916,13 @@ Object create o { :public method foo {} { set _ [join [list {*}[lsort [info vars :*]] [info locals :*] \ - [info exists w] [::nsf::existsvar [::nsf::current] w] \ - [info exists :x] [::nsf::existsvar [::nsf::current] x]] "-"] + [info exists w] [::nsf::var::exists [::nsf::current] w] \ + [info exists :x] [::nsf::var::exists [::nsf::current] x]] "-"] variable w; # -> intention: a variable "w" in the effective namespace (e.g., "::ns1::w") variable :x; # -> intention: a variable ":x" in the effective namespace (e.g., "::ns1:::x"!). append _ | [join [list {*}[lsort [info vars :*]] [info locals :*] \ - [info exists w] [::nsf::existsvar [::nsf::current] w] \ - [info exists :x] [::nsf::existsvar [::nsf::current] x]] "-"] + [info exists w] [::nsf::var::exists [::nsf::current] w] \ + [info exists :x] [::nsf::var::exists [::nsf::current] x]] "-"] return $_ } } @@ -934,20 +934,20 @@ set _ [join [list {*}[lsort [info vars :*]] [info locals :*] \ [namespace which -variable [namespace current]::w] \ [info exists [namespace current]::w] \ - [info exists w] [::nsf::existsvar [::nsf::current] w] \ + [info exists w] [::nsf::var::exists [::nsf::current] w] \ [namespace which -variable [namespace current]:::x] \ [info exists [namespace current]:::x] \ - [info exists :x] [::nsf::existsvar [::nsf::current] x]] "-"] + [info exists :x] [::nsf::var::exists [::nsf::current] x]] "-"] variable w 1; # -> intention: a variable "w" in the effective namespace (e.g., "::ns1::w") variable :x 2; # -> intention: a variable ":x" in the effective namespace (e.g., "::ns1:::x"!). append _ | [join [list {*}[lsort [info vars :*]] [info locals :*] \ [namespace which -variable [namespace current]::w] \ [info exists [namespace current]::w] \ - [info exists w] [::nsf::existsvar [::nsf::current] w] \ + [info exists w] [::nsf::var::exists [::nsf::current] w] \ [namespace which -variable [namespace current]:::x] \ [info exists [namespace current]:::x] [namespace eval [namespace current] {info exists :x}] \ [namespace eval [namespace current] {variable :x; info exists :x}] \ - [info exists :x] [::nsf::existsvar [::nsf::current] x]] "-"] + [info exists :x] [::nsf::var::exists [::nsf::current] x]] "-"] append _ | [join [list [expr {$w eq [namespace eval [namespace current] {variable w; set w}]}] \ [expr {${:x} eq [namespace eval [namespace current] {variable w; set :x}]}]] -] @@ -982,7 +982,7 @@ set :aaa 2 append _ "-${:aaa}-[set :aaa]-[namespace eval [namespace current] {variable :aaa; set :aaa}]" unset :aaa - append _ "-[info exists :aaa]-[namespace which -variable [namespace current]:::aaa]-[::nsf::existsvar [current] aaa]-[[current] eval {set :aaa}]" + append _ "-[info exists :aaa]-[namespace which -variable [namespace current]:::aaa]-[::nsf::var::exists [current] aaa]-[[current] eval {set :aaa}]" return $_ } } @@ -1023,7 +1023,7 @@ append _ "-${:aaa}-[set :aaa]-[[current] eval {set :aaa}]-[namespace eval [namespace current] {variable :aaa; info exists :aaa}]" variable :aaa 5 unset :aaa - append _ "-[info exists :aaa]-[namespace which -variable [namespace current]:::aaa]-[::nsf::existsvar [current] aaa]-[namespace eval [namespace current] {variable :aaa; info exists :aaa}]-[namespace eval [namespace current] {variable :aaa; set :aaa}]" + append _ "-[info exists :aaa]-[namespace which -variable [namespace current]:::aaa]-[::nsf::var::exists [current] aaa]-[namespace eval [namespace current] {variable :aaa; info exists :aaa}]-[namespace eval [namespace current] {variable :aaa; set :aaa}]" return $_ }} "1-1-1-1-2-2-2-0-0--0-1-5"