1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
|
<html><head>
<title>nx::Object - </title>
<link rel="stylesheet" href="man.css" type="text/css">
</head>
<! -- Generated from file 'Object.man' by tcllib/doctools with format 'html'
-->
<! -- Copyright © 2014 Stefan Sobernig <stefan.sobernig@wu.ac.at>, Gustaf Neumann <gustaf.neumann@wu.ac.at>; available under the Creative Commons Attribution 3.0 Austria license (CC BY 3.0 AT).
-->
<! -- CVS: $Id$ nx::Object.3
-->
<body><div class="doctools">
<h1 class="title">nx::Object(3) 2.0 Object ""</h1>
<div id="name" class="section"><h2><a name="name">Name</a></h2>
<p>nx::Object - API reference of the base class in the NX object system</p>
</div>
<div id="toc" class="section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="toc">
<li class="section"><a href="#toc">Table Of Contents</a></li>
<li class="section"><a href="#synopsis">Synopsis</a></li>
<li class="section"><a href="#section1">Description</a></li>
<li class="section"><a href="#section2">Configuration Options for Instances of nx::Object</a></li>
<li class="section"><a href="#section3">Methods for Instances of nx::Object</a></li>
<li class="section"><a href="#section4">Object Self-Reference</a></li>
<li class="section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="synopsis">
<ul class="syntax">
<li><a href="#1"><b class="cmd">nx::Object</b> <b class="method">create</b> <i class="arg">obj</i> <span class="opt">?<b class="option">-object-mixins</b> <i class="arg">mixinSpec</i>?</span> <span class="opt">?<b class="option">-class</b> <i class="arg">newClassName</i>?</span> <span class="opt">?<b class="option">-object-filters</b> <i class="arg">filterSpec</i>?</span> <span class="opt">?<i class="arg">initBlock</i>?</span></a></li>
<li><a href="#2"><b class="cmd">nx::Object</b> <b class="method">new</b> <span class="opt">?<b class="option">-object-mixins</b> <i class="arg">mixinSpec</i>?</span> <span class="opt">?<b class="option">-class</b> <i class="arg">newClassName</i>?</span> <span class="opt">?<b class="option">-object-filters</b> <i class="arg">filterSpec</i>?</span> <span class="opt">?<i class="arg">initBlock</i>?</span></a></li>
<li><a href="#3"><i class="arg">obj</i> <span class="opt">?<b class="method">public</b> | <b class="method">private</b> | <b class="method">protected</b>?</span> <b class="method">object alias</b> <i class="arg">methodName</i> <span class="opt">?<b class="option">-returns</b> <i class="arg">valueChecker</i>?</span> <span class="opt">?<b class="option">-frame</b> <b class="const">object</b> | <b class="const">method</b>?</span> <i class="arg">cmdName</i></a></li>
<li><a href="#4"><i class="arg">obj</i> <b class="method">cget</b> <i class="arg">configurationOption</i></a></li>
<li><a href="#5"><i class="arg">obj</i> <b class="method">configure</b> <span class="opt">?<i class="arg">configurationOption</i> <i class="arg">value</i> ...?</span></a></li>
<li><a href="#6"><i class="arg">obj</i> <b class="method">contains</b> <span class="opt">?-withnew <i class="arg">trueFalse</i>?</span> <span class="opt">?-object <i class="arg">objectName</i>?</span> <span class="opt">?-class <i class="arg">className</i>?</span> <i class="arg">cmds</i></a></li>
<li><a href="#7"><i class="arg">obj</i> <b class="method">copy</b> <i class="arg">newObjectName</i></a></li>
<li><a href="#8"><i class="arg">obj</i> <b class="method">delete object</b> <i class="arg">feature</i> <i class="arg">arg</i></a></li>
<li><a href="#9"><i class="arg">obj</i> <b class="method">destroy</b></a></li>
<li><a href="#10"><i class="arg">obj</i> <b class="method">eval</b> <i class="arg">arg</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></li>
<li><a href="#11"><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters</b> <i class="arg">submethod</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></li>
<li><a href="#12"><i class="arg">obj</i> <span class="opt">?<b class="method">public</b> | <b class="method">protected</b> | <b class="method">private</b>?</span> <b class="method">object forward</b> <i class="arg">methodName</i> <span class="opt">?<b class="option">-prefix</b> <i class="arg">prefixName</i>?</span> <span class="opt">?<b class="option">-frame</b> <b class="const">object</b>?</span> <span class="opt">?<b class="option">-returns</b> <i class="arg">valueChecker</i>?</span> <span class="opt">?<b class="option">-verbose</b>?</span> <span class="opt">?<i class="arg">target</i>?</span> <span class="opt">?<i class="arg">arg</i> ...?</span></a></li>
<li><a href="#13"><i class="arg">obj</i> <b class="method">info children</b> <span class="opt">?<b class="option">-type</b> <i class="arg">className</i>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></li>
<li><a href="#14"><i class="arg">obj</i> <b class="method">info class</b></a></li>
<li><a href="#15"><i class="arg">obj</i> <b class="method">info has</b> <span class="opt">?<b class="method">mixin</b> | <b class="method">namespace</b> | <b class="method">type</b>?</span> <span class="opt">?<i class="arg">arg</i> ...?</span></a></li>
<li><a href="#16"><i class="arg">obj</i> <b class="method">info lookup</b> <i class="arg">submethod</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></li>
<li><a href="#17"><i class="arg">obj</i> <b class="method">info name</b></a></li>
<li><a href="#18"><i class="arg">obj</i> <b class="method">info info</b> <span class="opt">?<b class="option">-asList</b>?</span></a></li>
<li><a href="#19"><i class="arg">obj</i> <b class="method">info object filters</b> <span class="opt">?<b class="option">-guards</b>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></li>
<li><a href="#20"><i class="arg">obj</i> <b class="method">info object method</b> <i class="arg">option</i> <i class="arg">methodName</i></a></li>
<li><a href="#21"><i class="arg">obj</i> <b class="method">info object methods</b> <span class="opt">?<b class="option">-callprotection</b> <i class="arg">level</i>?</span> <span class="opt">?<b class="option">-type</b> <i class="arg">methodType</i>?</span> <span class="opt">?<b class="option">-path</b>?</span> <span class="opt">?<i class="arg">namePattern</i>?</span></a></li>
<li><a href="#22"><i class="arg">obj</i> <b class="method">info object mixins</b> <span class="opt">?<b class="option">-guards</b>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></li>
<li><a href="#23"><i class="arg">obj</i> <b class="method">info object slots</b> <span class="opt">?<b class="option">-type</b> <i class="arg">className</i>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></li>
<li><a href="#24"><i class="arg">obj</i> <b class="method">info object variables</b> <span class="opt">?<i class="arg">pattern</i>?</span></a></li>
<li><a href="#25"><i class="arg">obj</i> <b class="method">info parent</b></a></li>
<li><a href="#26"><i class="arg">obj</i> <b class="method">info precedence</b> <span class="opt">?<b class="option">-intrinsic</b>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></li>
<li><a href="#27"><i class="arg">obj</i> <b class="method">info variable</b> <i class="arg">option</i> <i class="arg">handle</i></a></li>
<li><a href="#28"><i class="arg">obj</i> <b class="method">info vars</b> <span class="opt">?<i class="arg">pattern</i>?</span></a></li>
<li><a href="#29"><i class="arg">obj</i> <span class="opt">?<b class="method">public</b> | <b class="method">protected</b> | <b class="method">private</b>?</span> <b class="method">object method</b> <i class="arg">name</i> <i class="arg">parameters</i> <span class="opt">?<b class="option">-checkalways</b>?</span> <span class="opt">?<b class="option">-returns</b> <i class="arg">valueChecker</i>?</span> <i class="arg">body</i></a></li>
<li><a href="#30"><i class="arg">obj</i> <b class="method">move</b> <i class="arg">newObjectName</i></a></li>
<li><a href="#31"><i class="arg">obj</i> <b class="method">object mixins</b> <i class="arg">submethod</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></li>
<li><a href="#32"><i class="arg">obj</i> <b class="method">object property</b> <span class="opt">?<b class="option">-accessor</b> <b class="const">public</b> | <b class="const">protected</b> | <b class="const">private</b>?</span> <span class="opt">?<b class="option">-configurable</b> <i class="arg">trueFalse</i>?</span> <span class="opt">?<b class="option">-incremental</b>?</span> <span class="opt">?<b class="option">-class</b> <i class="arg">className</i>?</span> <span class="opt">?<b class="option">-nocomplain</b>?</span> <i class="arg">spec</i> <span class="opt">?<i class="arg">initBlock</i>?</span></a></li>
<li><a href="#33"><i class="arg">obj</i> <b class="method">require namespace</b></a></li>
<li><a href="#34"><i class="arg">obj</i> <b class="method">require</b> <span class="opt">?<b class="method">public</b> | <b class="method">protected</b> | <b class="method">private</b>?</span> <b class="method">object method</b> <i class="arg">methodName</i></a></li>
<li><a href="#35"><i class="arg">obj</i> <b class="method">unknown</b> <i class="arg">unknownMethodName</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></li>
<li><a href="#36"><i class="arg">obj</i> <b class="method">object variable</b> <span class="opt">?<b class="option">-accessor</b> <b class="const">public</b> | <b class="const">protected</b> | <b class="const">private</b>?</span> <span class="opt">?<b class="option">-incremental</b>?</span> <span class="opt">?<b class="option">-class</b> <i class="arg">className</i>?</span> <span class="opt">?<b class="option">-configurable</b> <i class="arg">trueFalse</i>?</span> <span class="opt">?<b class="option">-initblock</b> <i class="arg">script</i>?</span> <span class="opt">?<b class="option">-nocomplain</b>?</span> <i class="arg">spec</i> <span class="opt">?<i class="arg">defaultValue</i>?</span></a></li>
</ul>
</div>
</div>
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
<p><b class="cmd">nx::Object</b> is the base class of the NX object system. All
objects defined in NX are (direct or indirect) instances of this
base class. The methods provided by the <b class="cmd">nx::Object</b>
base class are available to all objects and to all classes defined in
NX.</p>
<pre class="example">
+---------+
| ::nx::* |
+---------+--------------------------------------Y
| |
| +---------+ instance of +----------+ |
| | |<....................| | |
| | Class | | Object | |
| | |....................>| | |
| +----+----+ subclass of +-----+----+ |
| ^ ^ ^ |
instance.|...........................|....|......./
of | | |
+-----+-----+ subclass of | | instance
| |.....................| | of
| /cls/ | (by default) |
| | |
+-----------+ |
^ |
instance |.............(xor)..............|
of | +-----------+ |
|.........| |..........|
| /obj/ |
| |
+-----------+
</pre>
<p>NX allows for creating and for using objects (e.g. <em>obj</em>) which are
instantiated from the base class <b class="cmd">nx::Object</b>
directly. Typical use cases are singletons and anonymous, inline
objects. In such use cases, NX does not require creating an
intermediate application class (e.g. <em>cls</em>), which specializes the base class
<b class="cmd">nx::Object</b> by default, beforehand.</p>
<p>Objects (e.g. <em>obj</em>) which are creating by instantiating a
previously defined application class (e.g. <em>cls</em>) are indirect
instances of <b class="cmd">nx::Object</b>.</p>
<p>Direct instances of <b class="cmd">nx::Object</b> can be created as follows:</p>
<dl class="definitions">
<dt><a name="1"><b class="cmd">nx::Object</b> <b class="method">create</b> <i class="arg">obj</i> <span class="opt">?<b class="option">-object-mixins</b> <i class="arg">mixinSpec</i>?</span> <span class="opt">?<b class="option">-class</b> <i class="arg">newClassName</i>?</span> <span class="opt">?<b class="option">-object-filters</b> <i class="arg">filterSpec</i>?</span> <span class="opt">?<i class="arg">initBlock</i>?</span></a></dt>
<dd><p>To create a direct instance of <b class="cmd">nx::Object</b> having an explicit name
<i class="arg">obj</i>, use <b class="method">create</b> on <b class="cmd">nx::Object</b>. Note that
<b class="method">create</b> is defined by <b class="cmd">nx::Class</b> and is available to <b class="cmd">nx::Object</b> being
an instance of <b class="cmd">nx::Class</b>. This way, singleton objects can be
created, for example.</p></dd>
<dt><a name="2"><b class="cmd">nx::Object</b> <b class="method">new</b> <span class="opt">?<b class="option">-object-mixins</b> <i class="arg">mixinSpec</i>?</span> <span class="opt">?<b class="option">-class</b> <i class="arg">newClassName</i>?</span> <span class="opt">?<b class="option">-object-filters</b> <i class="arg">filterSpec</i>?</span> <span class="opt">?<i class="arg">initBlock</i>?</span></a></dt>
<dd><p>To create a direct instance of <b class="cmd">nx::Object</b> having an
automatically assigned, implicit object name, use <b class="method">new</b> on <b class="cmd">nx::Object</b>. Note
that <b class="method">new</b> is defined by <b class="cmd">nx::Class</b> and is available to
<b class="cmd">nx::Object</b> being an instance of <b class="cmd">nx::Class</b>. Using <b class="method">new</b> allows
for creating anonymous, inline objects, for example.</p></dd>
</dl>
<p>The configuration options for direct and indirect instances of <b class="cmd">nx::Object</b>, which
can be passed when calling <b class="method">create</b> and <b class="method">new</b>, are
documented in the subsequent section.</p>
</div>
<div id="section2" class="section"><h2><a name="section2">Configuration Options for Instances of nx::Object</a></h2>
<p>Configuration options can be used for configuring objects
during their creation by passing the options as non-positional
arguments into calls of <b class="method">new</b> and <b class="method">create</b> (see <b class="cmd">nx::Class</b>). An
existing object can be queried for its current configuration using
<b class="method">cget</b> and it can be re-configured using <b class="method">configure</b>. Legal
configuration options are:</p>
<dl class="options">
<dt><b class="option">-class</b> <span class="opt">?<i class="arg">className</i>?</span></dt>
<dd><p>Retrieves the current class of the object or sets the object's class to <i class="arg">className</i>, if provided.</p></dd>
<dt><b class="option">-object-filters</b> <span class="opt">?<i class="arg">filterMethods</i>?</span></dt>
<dd><p>Retrieves the list of currently active per-object filter methods or sets
a list of per-object filter methods, if <i class="arg">filterMethods</i> is
provided.</p></dd>
<dt><b class="option">-object-mixins</b> <span class="opt">?<i class="arg">mixinSpecs</i>?</span></dt>
<dd><p>If <i class="arg">mixinSpecs</i> is not specified, retrieves the list of currently
active per-object mixin specifications. If <i class="arg">mixinSpecs</i> is
specified, sets a list of per-object mixin specifications to become
active. mixin classes are returned or set in terms of a list
of mixin specifications.</p></dd>
</dl>
</div>
<div id="section3" class="section"><h2><a name="section3">Methods for Instances of nx::Object</a></h2>
<dl class="commands">
<dt><b class="cmd">alias</b></dt>
<dd><dl class="definitions">
<dt><a name="3"><i class="arg">obj</i> <span class="opt">?<b class="method">public</b> | <b class="method">private</b> | <b class="method">protected</b>?</span> <b class="method">object alias</b> <i class="arg">methodName</i> <span class="opt">?<b class="option">-returns</b> <i class="arg">valueChecker</i>?</span> <span class="opt">?<b class="option">-frame</b> <b class="const">object</b> | <b class="const">method</b>?</span> <i class="arg">cmdName</i></a></dt>
<dd><p>Define an alias method for the given object. The
resulting method registers a pre-existing Tcl command <i class="arg">cmdName</i>
under the (alias) name <i class="arg">methodName</i> with the object. If <i class="arg">cmdName</i> refers
to another <b class="method">method</b>, the corresponding argument
should be a valid method handle. If a Tcl command (e.g., a
<b class="cmd">proc</b>), the argument should be a fully qualified Tcl command
name. If aliasing a subcommand (e.g., <b class="cmd">array exists</b>) of a Tcl namespace ensemble (e.g., <b class="cmd">array</b>), <i class="arg">cmdName</i> must hold the fully qualified subcommand name (and not the ensemble name of
the subcommand).</p>
<p>As for a regular <b class="method">object method</b>, <b class="option">-returns</b>
allows for setting a value checker on the values returned by
the aliased command <i class="arg">cmdName</i>.</p>
<p>When creating an alias method for
a <em>C-implemented</em> Tcl command (i.e., command defined using the
Tcl/NX C-API), <b class="option">-frame</b> sets the scope
for variable references used in the aliased command. If the provided
value is <b class="const">object</b>, then variable references will be resolved in the
context of the called object, i.e., the object upon which the alias method is
invoked, as if they were object variables. There is no need for using
the colon-prefix notation for identifying object variables. If the
value is <b class="const">method</b>, then the aliased command will be executed as a regular method call. The command is aware of its called-object context; i.e., it can resolve <b class="cmd">::nx::self</b>. In addition, the alias method has access to the method-call context (e.g., <b class="cmd">nx::next</b>). If <b class="option">-frame</b> is omitted, and by default, the variable references will resolve in the context of the caller of the alias method.</p></dd>
</dl></dd>
<dt><b class="cmd">cget</b></dt>
<dd><dl class="definitions">
<dt><a name="4"><i class="arg">obj</i> <b class="method">cget</b> <i class="arg">configurationOption</i></a></dt>
<dd><p>The method is used to obtain the current value of <i class="arg">configurationOption</i> for
<i class="arg">obj</i>. The configuration options
available for querying through <b class="method">cget</b> are determined by the
configurable properties defined by the class hierarchy of <i class="arg">obj</i>. The
queryable configuration options for <i class="arg">obj</i> can be
obtained by calling <b class="method">info configure</b>. The <i class="arg">configurationOption</i> can
be set and modified using <b class="method">configure</b>.</p>
<pre class="example">
% nx::Object create obj
::obj
% ::obj info configure
?-object-mixins /mixinreg .../? ?-class /class/? ?-object-filters /filterreg .../? ?/__initblock/?
% ::obj cget -class
::nx::Object
</pre>
</dd>
</dl></dd>
<dt><b class="cmd">configure</b></dt>
<dd><dl class="definitions">
<dt><a name="5"><i class="arg">obj</i> <b class="method">configure</b> <span class="opt">?<i class="arg">configurationOption</i> <i class="arg">value</i> ...?</span></a></dt>
<dd><p>This method sets configuration options on an object. The configuration
options available for setting on <i class="arg">obj</i> are determined by the
configurable properties defined by the class hierarchy of <i class="arg">obj</i>. The
settable configuration options for <i class="arg">obj</i> can be
obtained by calling <b class="method">info configure</b>. Furthermore, <b class="method">configure</b> is
also called during object construction. Under object construction, it receives
the arguments passed into calls of <b class="method">create</b> and <b class="method">new</b>. Options
set using <b class="method">configure</b> can be retrieved using <b class="method">cget</b>.</p>
<pre class="example">
% nx::Class create Foo {:property x}
::Foo
% Foo create f1 -x 101
::f1
% f1 cget -x
101
% f1 configure -x 200
% f1 cget -x
200
</pre>
</dd>
</dl></dd>
<dt><b class="cmd">contains</b></dt>
<dd><dl class="definitions">
<dt><a name="6"><i class="arg">obj</i> <b class="method">contains</b> <span class="opt">?-withnew <i class="arg">trueFalse</i>?</span> <span class="opt">?-object <i class="arg">objectName</i>?</span> <span class="opt">?-class <i class="arg">className</i>?</span> <i class="arg">cmds</i></a></dt>
<dd><p>This method acts as a builder for nested object structures. Object
and class construction statements passed to this method as its last
argument <i class="arg">cmds</i> are evaluated in a way so that the receiver object
<i class="arg">obj</i> becomes the parent of the newly constructed objects and
classes. This is realized by setting explicitly the namespace for
constructing relatively named objects. Fully qualified object names in
<i class="arg">cmds</i> evade the nesting.</p>
<p><b class="option">-withnew</b> requests the automatic rescoping of
objects created using <b class="method">new</b> so that they become nested into the
receiver object <i class="arg">obj</i>, rather than being created in the default
namespace for autonamed objects (i.e., ::nsf). If turned off,
autonamed objects do not become children of <i class="arg">obj</i>.</p>
<p>The parent object <i class="arg">objectName</i> to be used instead of <i class="arg">obj</i> can be specified
using <b class="option">-object</b>. If this explicitly set parent
object does not exist prior to calling <b class="method">contains</b>, it will be
created on the fly as a direct instance of <b class="cmd">nx::Object</b>. Alternatively,
using <b class="option">-class</b>, a class <i class="arg">className</i> other
than <b class="cmd">nx::Object</b> for the on-the-fly creation of <i class="arg">objectName</i>
can be provided.</p>
<pre class="example">
% nx::Class create Window {
:contains {
#
# Become children of Window, implicitly
#
nx::Class create Header; # Window::Header
nx::Object create Panel; # Window::Panel
}
#
# Explicitly declared a child of Window using [self]
#
nx::Class create [self]::Slider; # Window::Slider
#
# Fully-qualified objects do not become nested
#
nx::Class create ::Door; # ::Door
}
::Window
% ::Window info children
::Window::Panel ::Window::Header ::Window::Slider
</pre>
</dd>
</dl></dd>
<dt><b class="cmd">copy</b></dt>
<dd><dl class="definitions">
<dt><a name="7"><i class="arg">obj</i> <b class="method">copy</b> <i class="arg">newObjectName</i></a></dt>
<dd><p>Creates a full and deep copy of a source object <i class="arg">obj</i>. The
object's copy <i class="arg">newObjectName</i> features all structural and
behavioral properties of the source object, including object
variables, per-object methods, nested objects, slot objects,
namespaces, filters, mixins, and traces.</p></dd>
</dl></dd>
<dt><b class="cmd">delete</b></dt>
<dd><dl class="definitions">
<dt><a name="8"><i class="arg">obj</i> <b class="method">delete object</b> <i class="arg">feature</i> <i class="arg">arg</i></a></dt>
<dd><p>This method serves as the equivalent to Tcl's <b class="cmd">rename</b> for
removing structural (properties, variables) and behavioral features
(methods) of the object:</p></dd>
<dt><i class="arg">obj</i> <b class="method">delete object property</b> <i class="arg">propertyName</i></dt>
<dd></dd>
<dt><i class="arg">obj</i> <b class="method">delete object variable</b> <i class="arg">variableName</i></dt>
<dd></dd>
<dt><i class="arg">obj</i> <b class="method">delete object method</b> <i class="arg">methodName</i></dt>
<dd><p>Removes a property <i class="arg">propertyName</i>, variable <i class="arg">variableName</i>,
and method <i class="arg">methodName</i>, respectively, previously defined for the
scope of the object.</p>
<p><b class="method">delete object method</b> can be equally used for removing regular methods (see <b class="method">object method</b>), an alias method (see <b class="method">object alias</b>), and a forwarder method (see <b class="method">object forward</b>).</p></dd>
</dl></dd>
<dt><b class="cmd">destroy</b></dt>
<dd><dl class="definitions">
<dt><a name="9"><i class="arg">obj</i> <b class="method">destroy</b></a></dt>
<dd><p>This method allows for explicitly destructing an object <i class="arg">obj</i>,
potentially prior to <i class="arg">obj</i> being destroyed by the object system
(e.g. during the shutdown of the object system upon calling <b class="cmd">exit</b>):</p>
<pre class="example">[nx::Object new] destroy</pre>
<p>By providing a custom implementation of <b class="method">destroy</b>, the
destruction procedure of <i class="arg">obj</i> can be customized. Typically, once
the application-specific destruction logic has completed, a custom
<b class="method">destroy</b> will trigger the actual, physical object destruction
via <b class="cmd">next</b>.</p>
<pre class="example">
% [nx::Object create obj {
:public method destroy {} {
puts "destroying [self]"
next; # physical destruction
}
}] destroy
destroying ::obj
</pre>
<p>A customized object-destruction scheme can be made shared between the instances
of a class, by defining the custom <b class="method">destroy</b> for an
application class:</p>
<pre class="example">
% nx::Class create Foo {
:method destroy {} {
puts "destroying [self]"
next; # physical destruction
}
}
::Foo
% Foo create f1
::f1
% f1 destroy
destroying ::f1
</pre>
<p>Physical destruction is performed by clearing the in-memory object
storage of <i class="arg">obj</i>. This is achieved by passing <i class="arg">obj</i> into a
call to <b class="method">dealloc</b> provided by <b class="cmd">nx::Class</b>. A near, scripted
equivalent to the C-implemented <b class="method">destroy</b> provided by <b class="cmd">nx::Object</b> would look
as follows:</p>
<pre class="example">
% Object method destroy {} {
[:info class] dealloc [self]
}
</pre>
<p>Note, however, that <b class="method">destroy</b> is protected against
application-level redefinition. Trying to evaluate the above script snippet yields:</p>
<pre class="example">
refuse to overwrite protected method 'destroy'; derive e.g. a subclass!
</pre>
<p>A custom <b class="method">destroy</b> must be provided as a refinement in a
subclass of <b class="cmd">nx::Object</b> or in a mixin class.</p></dd>
</dl></dd>
<dt><b class="cmd">eval</b></dt>
<dd><dl class="definitions">
<dt><a name="10"><i class="arg">obj</i> <b class="method">eval</b> <i class="arg">arg</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></dt>
<dd><p>Evaluates a special Tcl script for the scope of <i class="arg">obj</i> in the style
of Tcl's <b class="cmd">eval</b>. There are, however, notable differences to the
standard <b class="cmd">eval</b>: In this script, the colon-prefix notation is available to
dispatch to methods and to access variables of <i class="arg">obj</i>. Script-local
variables, which are thrown away once the evaluation of the script has
completed, can be defined to store intermediate results.</p>
<pre class="example">
% nx::Object create obj {
:object property {bar 1}
:public object method foo {x} { return $x }
}
::obj
% ::obj eval {
set y [:foo ${:bar}]
}
1
</pre>
</dd>
</dl></dd>
<dt><b class="cmd">filters</b></dt>
<dd><dl class="definitions">
<dt><a name="11"><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters</b> <i class="arg">submethod</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></dt>
<dd><p>Accesses and modifies the list of methods which are registered as
filters with <i class="arg">obj</i> using a specific setter or getter
<i class="arg">submethod</i>:</p>
<dl class="definitions">
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters add</b> <i class="arg">spec</i> <span class="opt">?<i class="arg">index</i>?</span></dt>
<dd><p>Inserts a single filter into the current list of filters of <i class="arg">obj</i>. Using <i class="arg">index</i>, a position in the existing list of filters for inserting the new filter can be set. If
omitted, <i class="arg">index</i> defaults to the list head (0).</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters clear</b></dt>
<dd><p>Removes all filters from <i class="arg">obj</i> and returns the list of removed filters. Clearing
is equivalent to passing an empty list for <i class="arg">filterSpecList</i> to
<b class="const">object</b> <b class="method">filter set</b>.</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters delete</b> <span class="opt">?<b class="option">-nocomplain</b>?</span> <i class="arg">specPattern</i></dt>
<dd><p>Removes a single filter from the current list of filters of
<i class="arg">obj</i> whose spec matches <i class="arg">specPattern</i>. <i class="arg">specPattern</i> can
contain special matching chars (see <b class="cmd">string match</b>). <b class="const">object</b> <b class="method">filters delete</b> will
throw an error if there is no matching filter, unless
<b class="option">-nocomplain</b> is set.</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters get</b></dt>
<dd><p>Returns the list of current filter specifications registered for <i class="arg">obj</i>.</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters guard</b> <i class="arg">methodName</i> <span class="opt">?<i class="arg">expr</i>?</span></dt>
<dd><p>If <i class="arg">expr</i> is specified, registers a guard expression <i class="arg">expr</i> with a filter <i class="arg">methodName</i>. This requires that the filter <i class="arg">methodName</i> has been previously set using <b class="const">object</b> <b class="method">filters set</b> or added using
<b class="const">object</b> <b class="method">filters add</b>. <i class="arg">expr</i> must be a valid Tcl expression (see
<b class="cmd">expr</b>). An empty string for <i class="arg">expr</i> will clear the currently registered
guard expression for filter <i class="arg">methodName</i>.</p>
<p>If <i class="arg">expr</i> is omitted, returns the guard expression set on the
filter <i class="arg">methodName</i> defined for <i class="arg">obj</i>. If none
is available, an empty string will be returned.</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters methods</b> <span class="opt">?<i class="arg">pattern</i>?</span></dt>
<dd><p>If <i class="arg">pattern</i> is omitted, returns all filter names which are
defined by <i class="arg">obj</i>. By specifying <i class="arg">pattern</i>, the returned
filters can be limited to those whose names match <i class="arg">patterns</i> (see
<b class="cmd">string match</b>).</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">filters set</b> <i class="arg">filterSpecList</i></dt>
<dd><p><i class="arg">filterSpecList</i> takes a list of filter specs, with each spec being itself either a
one-element or a two-element list: <i class="arg">methodName</i> ?-guard <i class="arg">guardExpr</i>?. <i class="arg">methodName</i> identifies
an existing method of <i class="arg">obj</i> which becomes
registered as a filter. If having three elements, the third
element <i class="arg">guardExpr</i> will be stored as a guard expression of the
filter. This guard expression must be a valid Tcl expression
(see <b class="cmd">expr</b>). <i class="arg">expr</i> is evaluated when <i class="arg">obj</i> receives a message to determine whether the
filter should intercept the message. Guard expressions
allow for realizing context-dependent or conditional filter
composition.</p></dd>
</dl>
<p>Every <i class="arg">methodName</i> in a <i class="arg">spec</i> must resolve to an existing method in
the scope of the object. To
access and to manipulate the list of filters of <i class="arg">obj</i>,
<b class="method">cget</b>|<b class="method">configure</b> <b class="option">-object-filters</b> can also be used.</p></dd>
</dl></dd>
<dt><b class="cmd">forward</b></dt>
<dd><dl class="definitions">
<dt><a name="12"><i class="arg">obj</i> <span class="opt">?<b class="method">public</b> | <b class="method">protected</b> | <b class="method">private</b>?</span> <b class="method">object forward</b> <i class="arg">methodName</i> <span class="opt">?<b class="option">-prefix</b> <i class="arg">prefixName</i>?</span> <span class="opt">?<b class="option">-frame</b> <b class="const">object</b>?</span> <span class="opt">?<b class="option">-returns</b> <i class="arg">valueChecker</i>?</span> <span class="opt">?<b class="option">-verbose</b>?</span> <span class="opt">?<i class="arg">target</i>?</span> <span class="opt">?<i class="arg">arg</i> ...?</span></a></dt>
<dd><p>Define a forward method for the given object. The
definition of a forward method registers a predefined, but
changeable list of forwarder arguments under the (forwarder) name <i class="arg">methodName</i>. Upon
calling the forward method, the forwarder
arguments are evaluated as a Tcl command call. That is, if present, <i class="arg">target</i>
is interpreted as a Tcl command (e.g., a Tcl <b class="cmd">proc</b> or an object)
and the remainder of the forwarder arguments <i class="arg">arg</i> as arguments passed into
this command. The actual method arguments to the invocation of the
forward method itself are appended to the list of forwarder
arguments.
If <i class="arg">target</i> is omitted, the value of <i class="arg">methodName</i> is
implicitly set and used as <i class="arg">target</i>. This way, when providing a
fully-qualified Tcl command name as <i class="arg">methodName</i> without <i class="arg">target</i>, the
unqualified <i class="arg">methodName</i> (<b class="cmd">namespace tail</b>) is used as the
forwarder name; while the fully-qualified one serves as the <i class="arg">target</i>.</p>
<p>As for a regular <b class="method">object method</b>, <b class="option">-returns</b> allows
for setting a value checker on the values returned by the
resulting Tcl command call. When passing <b class="const">object</b> to <b class="option">-frame</b>, the
resulting Tcl command is evaluated in the context of the object
receiving the forward method call. This way, variable names
used in the resulting execution of a command become resolved as
object variables.</p>
<p>The list of forwarder arguments <i class="arg">arg</i> can contain as its elements
a mix of literal values and placeholders. Placeholders are prefixed
with a percent symbol (%) and substituted for concrete values upon
calling the forward method. These placeholders allow for
constructing and for manipulating the arguments to be passed into the
resulting command call on the fly:</p>
<ul class="itemized">
<li><p><b class="const">%method</b> becomes substituted for the name of the forward method, i.e. <i class="arg">methodName</i>.</p></li>
<li><p><b class="const">%self</b> becomes substituted for the name of the object receiving the call of the forward method.</p></li>
<li><p><b class="const">%1</b> becomes substituted for the first method argument passed to the call of forward method. This requires, in turn, that <em>at least</em> one argument is passed along with the method call.</p>
<p>Alternatively, <b class="const">%1</b> accepts an optional argument <i class="arg">defaults</i>: {<b class="const">%1</b> <i class="arg">defaults</i>}.
<i class="arg">defaults</i> must be a valid Tcl list of two elements. For the first
element, <b class="const">%1</b> is substituted when there is no first method
argument which can be consumed by <b class="const">%1</b>. The second element is
inserted upon availability of a first method argument with the
consumed argument being appended right after the second list
element. This placeholder is typically used to define a pair of
getter/setter methods.</p></li>
<li><p>{<b class="const">%@</b><i class="arg">index</i> <i class="arg">value</i>} becomes substituted for the
specified <i class="arg">value</i> at position <i class="arg">index</i> in the
forwarder-arguments list, with <i class="arg">index</i> being either a positive
integer, a negative integer, or the literal value <b class="const">end</b> (such as
in Tcl's <b class="cmd">lindex</b>). Positive integers specify a list position
relative to the list head, negative integers give a position relative
to the list tail. Indexes for positioning placeholders in the definition of a
forward method are evaluated from left to right and should be
used in ascending order.</p>
<p>Note that <i class="arg">value</i> can be a literal or any of the placeholders
(e.g., <b class="const">%method</b>, <b class="const">%self</b>). Position prefixes are
exempted, they are evaluated as <b class="const">%</b><i class="arg">cmdName</i>-placeholders in this context.</p></li>
<li><p>{<b class="const">%argclindex</b> <i class="arg">list</i>} becomes substituted for the
<em>n</em>th element of the provided <i class="arg">list</i> , with <em>n</em>
corresponding to the number of method arguments passed to the forward method call.</p></li>
<li><p><b class="const">%%</b> is substituted for a single, literal percent symbol (%).</p></li>
<li><p><b class="const">%</b><i class="arg">cmdName</i> is substituted for the value returned
from executing the Tcl command <i class="arg">cmdName</i>. To pass arguments to <i class="arg">cmdName</i>, the placeholder should be wrapped into a Tcl <b class="cmd">list</b>: {<b class="const">%</b><i class="arg">cmdName</i> <span class="opt">?<i class="arg">arg</i> ...?</span>}.</p>
<p>Consider using fully-qualified Tcl command names for <i class="arg">cmdName</i> to
avoid possible name conflicts with the predefined placeholders, e.g.,
<b class="const">%self</b> vs. %<b class="cmd">::nx::self</b>.</p></li>
</ul>
<p>To disambiguate the names of subcommands or methods, which potentially
become called by a forward method, a prefix <i class="arg">prefixName</i>
can be set using <b class="option">-prefix</b>. This prefix is prepended
automatically to the argument following <i class="arg">target</i> (i.e., a second
argument), if present. If missing, <b class="option">-prefix</b> has no
effect on the forward method call.</p>
<p>To inspect and to debug the conversions performed by the above
placeholders, setting the switch <b class="option">-verbose</b>
will have the command list to be executed (i.e., after substitution)
printed using <b class="cmd">::nsf::log</b> (debugging level: <b class="const">notice</b>) upon
calling the forward method.</p></dd>
</dl></dd>
<dt><b class="cmd">info</b></dt>
<dd><dl class="definitions">
<dt><a name="13"><i class="arg">obj</i> <b class="method">info children</b> <span class="opt">?<b class="option">-type</b> <i class="arg">className</i>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></dt>
<dd><p>Retrieves the list of nested (or aggregated) objects of <i class="arg">obj</i>. The
resulting list contains the fully qualified names of the nested
objects. If <b class="option">-type</b> is set, only nested objects which are
direct or indirect instances of class <i class="arg">className</i> are
returned. Using <i class="arg">pattern</i>, only nested objects whose names match
<i class="arg">pattern</i> are returned. The <i class="arg">pattern</i> string can contain
special matching characters (see <b class="cmd">string match</b>). This method
allows for introspecting on <b class="method">contains</b>.</p></dd>
<dt><a name="14"><i class="arg">obj</i> <b class="method">info class</b></a></dt>
<dd><p>Returns the fully qualified name of the current <b class="cmd">nx::Class</b> of
<i class="arg">obj</i>. In case of re-classification (see <b class="method">configure</b>), the
returned class will be different from the <b class="cmd">nx::Class</b> from which <i class="arg">obj</i> was
originally instantiated using <b class="method">create</b> or <b class="method">new</b>.</p></dd>
<dt><a name="15"><i class="arg">obj</i> <b class="method">info has</b> <span class="opt">?<b class="method">mixin</b> | <b class="method">namespace</b> | <b class="method">type</b>?</span> <span class="opt">?<i class="arg">arg</i> ...?</span></a></dt>
<dd><dl class="definitions">
<dt><i class="arg">obj</i> <b class="method">info method has mixin</b> <i class="arg">className</i></dt>
<dd><p>Verifies whether <i class="arg">obj</i> has a given <b class="cmd">nx::Class</b> <i class="arg">className</i> registered as a mixin class (returns: <b class="const">true</b>) or not (returns: <b class="const">false</b>).</p></dd>
<dt><i class="arg">obj</i> <b class="method">info has namespace</b></dt>
<dd><p>Checks whether the object has a companion Tcl namespace (returns:
<b class="const">true</b>) or not (returns: <b class="const">false</b>). The namespace could
have been created using, for example, <b class="method">object require namespace</b>.</p></dd>
<dt><i class="arg">obj</i> <b class="method">info has type</b> <i class="arg">className</i></dt>
<dd><p>Tests whether the <b class="cmd">nx::Class</b> <i class="arg">className</i> is a type of the
object (returns: <b class="const">true</b>) or not (returns: <b class="const">false</b>). That
is, the method checks whether the object is a direct instance of <i class="arg">className</i> or
an indirect instance of one of the superclasses of <i class="arg">className</i>.</p></dd>
</dl></dd>
<dt><a name="16"><i class="arg">obj</i> <b class="method">info lookup</b> <i class="arg">submethod</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></dt>
<dd><p>A collection of submethods to retrieve structural features (e.g.
configuration options, slot objects) and behavioral
features (e.g. methods, filters) available for <i class="arg">obj</i> from the perspective of a client to <i class="arg">obj</i>. Features provided by <i class="arg">obj</i> itself and by the classes in its current linearization list are considered.</p>
<dl class="definitions">
<dt><i class="arg">obj</i> <b class="method">info lookup configure parameters</b> <span class="opt">?<i class="arg">namePattern</i>?</span></dt>
<dd><p>Returns all configuration options available for <i class="arg">obj</i> as a list of
method-parameter definitions. They can be used, for example, to
define a custom method refinement for <b class="method">configure</b>. The returned
configuration options can be limited to those whose names match <i class="arg">pattern</i>
(see <b class="cmd">string match</b>).</p></dd>
<dt><i class="arg">obj</i> <b class="method">info lookup configure syntax</b></dt>
<dd><p>Returns all configuration options available for <i class="arg">obj</i> as a
concrete-syntax description to be used in human-understandable
messages (e.g. errors or warnings, documentation strings).</p></dd>
<dt><i class="arg">obj</i> <b class="method">info lookup filter</b> <i class="arg">name</i></dt>
<dd><p>Returns the method handle for the filter method <i class="arg">name</i>, if
currently registered. If there is no filter <i class="arg">name</i> registered, an
empty string is returned.</p></dd>
<dt><i class="arg">obj</i> <b class="method">info lookup filters</b> <span class="opt">?<b class="option">-guards</b>?</span> <span class="opt">?<i class="arg">namePattern</i>?</span></dt>
<dd><p>Returns the method handles of all filters which are active on <i class="arg">obj</i>. By
turning on the switch <b class="option">-guards</b>, the corresponding guard
expressions, if any, are also reported for each filter as a three-element list: <i class="arg">methodHandle</i> -guard <i class="arg">guardExpr</i>. The returned filters can be limited to
those whose names match <i class="arg">namePattern</i> (see <b class="cmd">string match</b>).</p></dd>
<dt><i class="arg">obj</i> <b class="method">info lookup method</b> <i class="arg">name</i></dt>
<dd><p>Returns the method handle for a method <i class="arg">name</i> if a
so-named method can be invoked on <i class="arg">obj</i>. If there is no method
<i class="arg">name</i>, an empty string is returned.</p></dd>
<dt><i class="arg">obj</i> <b class="method">info lookup methods</b> <span class="opt">?<i class="arg">namePattern</i>?</span></dt>
<dd><p>Returns the names of all methods (including aliases and forwarders)
which can be invoked on <i class="arg">obj</i>. The returned methods can be limited
to those whose names match <i class="arg">namePattern</i> (see <b class="cmd">string match</b>).</p></dd>
<dt><i class="arg">obj</i> <b class="method">info lookup mixins</b> <span class="opt">?<b class="option">-guards</b>?</span> <span class="opt">?<i class="arg">namePattern</i>?</span></dt>
<dd><p>Returns the object names of all mixin classes which are
currently active on <i class="arg">obj</i>. By turning on the switch <b class="option">-guards</b>, the corresponding guard expressions, if any, are also reported as a
three-element list for each mixin class: <i class="arg">className</i>
-guard <i class="arg">guardExpr</i>. The returned mixin classes can be
limited to those whose names match <i class="arg">namePattern</i> (see <b class="cmd">string match</b>).</p></dd>
<dt><i class="arg">obj</i> <b class="method">info lookup slots</b> <span class="opt">?<b class="option">-type</b> <i class="arg">className</i>?</span> <span class="opt">?<b class="option">-source</b> all | application | system?</span> <span class="opt">?<i class="arg">namePattern</i>?</span></dt>
<dd><p>Returns the command names of all slot objects responsible for
managing properties, variables, and relations of <i class="arg">obj</i>. The
returned slot objects can be limited according to any or a
combination of the following criteria: First, slot objects
can be filtered based on their command names matching <i class="arg">namePattern</i> (see <b class="cmd">string
match</b>). Second, <b class="option">-type</b> allows one to select
slot objects which are instantiated from a subclass <i class="arg">className</i> of <b class="cmd">nx::Slot</b> (default: <b class="cmd">nx::Slot</b>) . Third, <b class="option">-source</b> restricts slot objects returned according to their provenance in either the NX <em>system</em> classes or the <em>application</em> classes present in the linearization list of <i class="arg">obj</i> (default: <em>all</em>).</p>
<p>To extract details of each slot object, use the <b class="method">info</b>
submethods available for each slot object.</p></dd>
<dt><i class="arg">obj</i> <b class="method">info lookup variables</b></dt>
<dd><p>Returns the command names of all slot objects responsible for
managing properties and variables of <i class="arg">obj</i>, if provided by <i class="arg">obj</i> or the classes in the linearization list of <i class="arg">obj</i>.</p>
<p>This is equivalent to calling: <i class="arg">obj</i> <b class="method">info lookup slots</b> -type ::nx::VariableSlot -source all <span class="opt">?<i class="arg">namePattern</i>?</span>.</p>
<p>To extract details of each slot object, use the <b class="method">info</b>
submethods available for each slot object.</p></dd>
</dl></dd>
<dt><a name="17"><i class="arg">obj</i> <b class="method">info name</b></a></dt>
<dd><p>Returns the unqualified name of an object, i.e., the object name
without any namespace qualifiers.</p></dd>
<dt><a name="18"><i class="arg">obj</i> <b class="method">info info</b> <span class="opt">?<b class="option">-asList</b>?</span></a></dt>
<dd><p>Returns the available submethods of the <b class="method">info</b> method ensemble for
<i class="arg">obj</i>, either as a pretty-printed string or as a
Tcl list (if the switch <b class="option">-asList</b> is set) for further
processing.</p></dd>
<dt><a name="19"><i class="arg">obj</i> <b class="method">info object filters</b> <span class="opt">?<b class="option">-guards</b>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></dt>
<dd><p>If <i class="arg">pattern</i> is omitted, returns all filter names which are
defined by <i class="arg">obj</i>. By turning on the switch <b class="option">-guards</b>, the
corresponding guard expressions, if any, are also
reported along with each filter as a three-element list: <i class="arg">filterName</i> -guard
<i class="arg">guardExpr</i>. By specifying <i class="arg">pattern</i>, the
returned filters can be limited to those whose names match <i class="arg">patterns</i> (see
<b class="cmd">string match</b>).</p></dd>
<dt><a name="20"><i class="arg">obj</i> <b class="method">info object method</b> <i class="arg">option</i> <i class="arg">methodName</i></a></dt>
<dd><p>This introspection submethod provides access to the details
of <i class="arg">methodName</i> provided by <i class="arg">obj</i>. Permitted values for
<i class="arg">option</i> are:</p>
<ul class="itemized">
<li><p><b class="const">args</b> returns a list containing the parameter names of
<i class="arg">methodName</i>, in order of the method-parameter specification.</p></li>
<li><p><b class="const">body</b> returns the body script of <i class="arg">methodName</i>.</p></li>
<li><p><b class="const">definition</b> returns a canonical command list which allows for (re-)define <i class="arg">methodName</i>.</p></li>
<li><p><b class="const">definitionhandle</b> returns the method handle for a submethod in a method ensemble from the perspective of <i class="arg">obj</i> as method provider. <i class="arg">methodName</i> must contain a complete method path.</p></li>
<li><p><b class="const">exists</b> returns 1 if there is a <i class="arg">methodName</i> provided by <i class="arg">obj</i>, returns 0 otherwise.</p></li>
<li><p><b class="const">handle</b> returns the method handle for <i class="arg">methodName</i>.</p></li>
<li><p><b class="const">origin</b> returns the aliased command if <i class="arg">methodName</i> is an alias method, or an empty string otherwise.</p></li>
<li><p><b class="const">parameters</b> returns the parameter specification of <i class="arg">methodName</i> as
a list of parameter names and type specifications.</p></li>
<li><p><b class="const">registrationhandle</b> returns the method handle for a submethod in a method ensemble from the perspective of the method caller. <i class="arg">methodName</i> must contain a complete method path.</p></li>
<li><p><b class="const">returns</b> gives the type specification defined
for the return value of <i class="arg">methodName</i>.</p></li>
<li><p><b class="const">submethods</b> returns the names of all submethods of <i class="arg">methodName</i>, if <i class="arg">methodName</i> is a method ensemble. Otherwise, an empty string is returned.</p></li>
<li><p><b class="const">syntax</b> returns the method parameters of <i class="arg">methodName</i> as a
concrete-syntax description to be used in human-understandable
messages (e.g., errors or warnings, documentation strings).</p></li>
<li><p><b class="const">type</b> returns whether <i class="arg">methodName</i> is a <em>scripted</em> method, an <em>alias</em> method, a <em>forwarder</em> method, or a <em>setter</em> method.</p></li>
</ul></dd>
<dt><a name="21"><i class="arg">obj</i> <b class="method">info object methods</b> <span class="opt">?<b class="option">-callprotection</b> <i class="arg">level</i>?</span> <span class="opt">?<b class="option">-type</b> <i class="arg">methodType</i>?</span> <span class="opt">?<b class="option">-path</b>?</span> <span class="opt">?<i class="arg">namePattern</i>?</span></a></dt>
<dd><p>Returns the names of all methods defined by <i class="arg">obj</i>. Methods
covered include those defined using <b class="method">object alias</b>
and <b class="method">object forward</b>. The returned methods can be limited
to those whose names match <i class="arg">namePattern</i> (see <b class="cmd">string match</b>).</p>
<p>By setting <b class="option">-callprotection</b>, only methods of a certain call protection <i class="arg">level</i> (<b class="const">public</b>, <b class="const">protected</b>, or <b class="const">private</b>) will be returned. Methods of a specific type can be requested using <b class="option">-type</b>. The recognized values for <i class="arg">methodType</i> are:</p>
<ul class="itemized">
<li><p><b class="const">scripted</b> denotes methods defined using <b class="const">object</b> <b class="method">method</b>;</p></li>
<li><p><b class="const">alias</b> denotes alias methods defined using <b class="const">object</b> <b class="method">alias</b>;</p></li>
<li><p><b class="const">forwarder</b> denotes forwarder methods defined using <b class="const">object</b> <b class="method">forward</b>;</p></li>
<li><p><b class="const">setter</b> denotes methods defined using <b class="cmd">::nsf::setter</b>;</p></li>
<li><p><b class="const">all</b> returns methods of any type, without restrictions (also the default value);</p></li>
</ul></dd>
<dt><a name="22"><i class="arg">obj</i> <b class="method">info object mixins</b> <span class="opt">?<b class="option">-guards</b>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></dt>
<dd><p>If <i class="arg">pattern</i> is omitted, returns the object names of the mixin classes which
extend <i class="arg">obj</i> directly. By turning on the switch <b class="option">-guards</b>,
the corresponding guard expressions, if any, are also
reported along with each mixin as a three-element list: <i class="arg">className</i>
-guard <i class="arg">guardExpr</i>. The returned mixin classes can be limited to those whose names
match <i class="arg">patterns</i> (see <b class="cmd">string match</b>).</p></dd>
<dt><a name="23"><i class="arg">obj</i> <b class="method">info object slots</b> <span class="opt">?<b class="option">-type</b> <i class="arg">className</i>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></dt>
<dd><p>If <i class="arg">pattern</i> is not specified, returns the object names of all slot objects defined by <i class="arg">obj</i>. The returned slot objects can be limited according to any or a
combination of the following criteria: First, slot objects
can be filtered based on their command names matching <i class="arg">pattern</i> (see <b class="cmd">string
match</b>). Second, <b class="option">-type</b> allows one to select
slot objects which are instantiated from a subclass <i class="arg">className</i> of <b class="cmd">nx::Slot</b> (default: <b class="cmd">nx::Slot</b>).</p></dd>
<dt><a name="24"><i class="arg">obj</i> <b class="method">info object variables</b> <span class="opt">?<i class="arg">pattern</i>?</span></a></dt>
<dd><p>If <i class="arg">pattern</i> is omitted, returns the object names of all slot objects provided
by <i class="arg">obj</i> which are responsible for managing properties and variables of <i class="arg">obj</i>. Otherwise,
only slot objects whose names match <i class="arg">pattern</i> are
returned.</p>
<p>This is equivalent to calling: <i class="arg">obj</i> <b class="method">info object slots</b> <b class="option">-type</b> <b class="cmd">::nx::VariableSlot</b> <i class="arg">pattern</i>.</p>
<p>To extract details of each slot object, use the <b class="method">info</b>
submethods available for each slot object.</p></dd>
<dt><a name="25"><i class="arg">obj</i> <b class="method">info parent</b></a></dt>
<dd><p>Returns the fully qualified name of the parent object of <i class="arg">obj</i>, if
any. If there is no parent object, the name of the Tcl
namespace containing <i class="arg">obj</i> (e.g. "::") will be reported.</p></dd>
<dt><a name="26"><i class="arg">obj</i> <b class="method">info precedence</b> <span class="opt">?<b class="option">-intrinsic</b>?</span> <span class="opt">?<i class="arg">pattern</i>?</span></a></dt>
<dd><p>Lists the classes from which <i class="arg">obj</i> inherits structural (e.g.
properties) and behavioral features (e.g. methods) and methods, in
order of the linearization scheme in NX. By setting the
switch <b class="option">-intrinsic</b>, only classes which participate in
superclass/subclass relationships (i.e., intrinsic classes) are
returned. If a <i class="arg">pattern</i> is provided only classes whose
names match <i class="arg">pattern</i> are returned. The <i class="arg">pattern</i> string can
contain special matching characters (see <b class="cmd">string match</b>).</p></dd>
<dt><a name="27"><i class="arg">obj</i> <b class="method">info variable</b> <i class="arg">option</i> <i class="arg">handle</i></a></dt>
<dd><p>Retrieves selected details about a variable represented by the given
<i class="arg">handle</i>. A <i class="arg">handle</i> can be obtained by querying <i class="arg">obj</i> using
<b class="method">info object variables</b> and <b class="method">info lookup variables</b>.
Valid values for <i class="arg">option</i> are:</p>
<ul class="itemized">
<li><p><b class="const">name</b> returns the variable name.</p></li>
<li><p><b class="const">parameter</b> returns a canonical parameter specification
eligible to (re-)define the given variable (e.g. using <b class="method">object variable</b>) in a new context.</p></li>
<li><p><b class="const">definition</b> returns a canonical representation of the definition command used to create the variable in its current configuration.</p></li>
</ul></dd>
<dt><a name="28"><i class="arg">obj</i> <b class="method">info vars</b> <span class="opt">?<i class="arg">pattern</i>?</span></a></dt>
<dd><p>Yields a list of Tcl variable names created and defined for the scope of
<i class="arg">obj</i>, i.e., object variables. The list can be limited to object variables whose names
match <i class="arg">pattern</i>. The <i class="arg">pattern</i> string can contain special
matching characters (see <b class="cmd">string match</b>).</p></dd>
</dl></dd>
<dt><b class="cmd">method</b></dt>
<dd><dl class="definitions">
<dt><a name="29"><i class="arg">obj</i> <span class="opt">?<b class="method">public</b> | <b class="method">protected</b> | <b class="method">private</b>?</span> <b class="method">object method</b> <i class="arg">name</i> <i class="arg">parameters</i> <span class="opt">?<b class="option">-checkalways</b>?</span> <span class="opt">?<b class="option">-returns</b> <i class="arg">valueChecker</i>?</span> <i class="arg">body</i></a></dt>
<dd><p>Defines a scripted method <i class="arg">methodName</i> for the scope of the object. The
method becomes part of the object's signature interface. Besides
a <i class="arg">methodName</i>, the method definition specifies
the method <i class="arg">parameters</i> and a method <i class="arg">body</i>.</p>
<p><i class="arg">parameters</i> accepts a Tcl <b class="cmd">list</b> containing an arbitrary
number of non-positional and positional parameter definitions. Each parameter
definition comprises a parameter name, a parameter-specific value checker, and
parameter options.</p>
<p>The <i class="arg">body</i> contains the method implementation as a script block. In this body script, the
colon-prefix notation is available to denote an object variable and
a self call. In addition, the context of the object receiving the
method call (i.e., the message) can be accessed (e.g., using <b class="cmd">nx::self</b>) and
the call stack can be introspected (e.g., using <b class="cmd">nx::current</b>).</p>
<p>Optionally, <b class="option">-returns</b> allows for setting a value checker on
values returned by the method implementation. By setting
the switch <b class="option">-checkalways</b>, value checking on
arguments and return value is guaranteed to be performed, even if
value checking is temporarily disabled; see <b class="cmd">nx::configure</b>).</p>
<p>A method closely resembles a Tcl <b class="cmd">proc</b>, but it differs in some
important aspects: First, a method can define non-positional
parameters and value checkers on arguments. Second, the script
implementing the method body can contain object-specific notation and
commands (see above). Third, method calls <em>cannot</em> be intercepted
using Tcl <b class="cmd">trace</b>. Note that an existing Tcl <b class="cmd">proc</b> can be registered as
an alias method with the object (see <b class="method">object alias</b>).</p></dd>
</dl></dd>
<dt><b class="cmd">move</b></dt>
<dd><dl class="definitions">
<dt><a name="30"><i class="arg">obj</i> <b class="method">move</b> <i class="arg">newObjectName</i></a></dt>
<dd><p>Effectively renames an object. First, the source object <i class="arg">obj</i> is
cloned into a target object <i class="arg">newObjectName</i> using <b class="method">copy</b>. Second,
the source object <i class="arg">obj</i> is destroyed by invoking <b class="method">destroy</b>.
<b class="method">move</b> is also called internally when <b class="cmd">rename</b> is
performed for a Tcl command representing an object.</p></dd>
</dl></dd>
<dt><b class="cmd">mixins</b></dt>
<dd><dl class="definitions">
<dt><a name="31"><i class="arg">obj</i> <b class="method">object mixins</b> <i class="arg">submethod</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></dt>
<dd><p>Accesses and modifies the list of mixin classes of
<i class="arg">obj</i> using a specific setter or getter <i class="arg">submethod</i>:</p>
<dl class="definitions">
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">mixins add</b> <i class="arg">spec</i> <span class="opt">?<i class="arg">index</i>?</span></dt>
<dd><p>Inserts a single mixin class into the current list of mixin classes of <i class="arg">obj</i>. Using <i class="arg">index</i>, a position in the existing list of mixin classes for inserting the new mixin class can be set. If
omitted, <i class="arg">index</i> defaults to the list head (0).</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">mixins classes</b> <span class="opt">?<i class="arg">pattern</i>?</span></dt>
<dd><p>If <i class="arg">pattern</i> is omitted, returns the object names of the mixin classes which
extend <i class="arg">obj</i> directly. By specifying <i class="arg">pattern</i>, the returned mixin classes can
be limited to those whose names match <i class="arg">pattern</i> (see <b class="cmd">string match</b>).</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">mixins clear</b></dt>
<dd><p>Removes all mixin classes from <i class="arg">obj</i> and returns the list of removed mixin classes. Clearing is equivalent to passing an empty list for <i class="arg">mixinSpecList</i> to
<b class="const">object</b> <b class="method">mixins set</b>.</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">mixins delete</b> <span class="opt">?<b class="option">-nocomplain</b>?</span> <i class="arg">specPattern</i></dt>
<dd><p>Removes a mixin class from a current list of mixin classes of <i class="arg">obj</i> whose spec matches <i class="arg">specPattern</i>. <i class="arg">specPattern</i> can contain special matching chars (see <b class="cmd">string match</b>). <b class="const">object</b> <b class="method">mixins delete</b> will throw an error if there is no matching mixin class, unless <b class="option">-nocomplain</b> is set.</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">mixins get</b></dt>
<dd><p>Returns the list of current mixin specifications.</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">mixins guard</b> <i class="arg">className</i> <span class="opt">?<i class="arg">expr</i>?</span></dt>
<dd><p>If <i class="arg">expr</i> is specified, a guard expression <i class="arg">expr</i> is registered with the mixin class <i class="arg">className</i>. This requires that the corresponding mixin class <i class="arg">className</i> has been previously set using <b class="const">object</b> <b class="method">mixins set</b> or added using <b class="const">object</b> <b class="method">mixins add</b>. <i class="arg">expr</i> must be a valid Tcl expression (see
<b class="cmd">expr</b>). An empty string for <i class="arg">expr</i> will clear the currently registered
guard expression for the mixin class <i class="arg">className</i>.</p>
<p>If <i class="arg">expr</i> is not specified, returns the active guard
expression. If none is available, an empty string will be returned.</p></dd>
<dt><i class="arg">obj</i> <b class="const">object</b> <b class="method">mixins set</b> <i class="arg">mixinSpecList</i></dt>
<dd><p><i class="arg">mixinSpecList</i> represents a list of mixin class specs, with each spec being itself either a one-element or a three-element list: <i class="arg">className</i> ?-guard <i class="arg">guardExpr</i>?. If
having one element, the element will be considered the <i class="arg">className</i>
of the mixin class. If having three elements, the third
element <i class="arg">guardExpr</i> will be stored as a guard expression of the
mixin class. This guard expression will be evaluated using
<b class="cmd">expr</b> when <i class="arg">obj</i> receives a message to determine if the mixin
is to be considered during method dispatch or not. Guard expressions
allow for realizing context-dependent or conditional mixin
composition.</p></dd>
</dl>
<p>At the time of setting the mixin relation, that is, calling <b class="const">object</b> <b class="method">mixins</b>, every
<i class="arg">className</i> as part of a spec must be an existing instance of <b class="cmd">nx::Class</b>. To
access and to manipulate the list of mixin classes of <i class="arg">obj</i>,
<b class="method">cget</b>|<b class="method">configure</b> <b class="option">-object-mixins</b> can also be used.</p></dd>
</dl></dd>
<dt><b class="cmd">__object_configureparameter</b></dt>
<dd><dl class="definitions">
<dt><i class="arg">obj</i> <b class="method">__object_configureparameter</b></dt>
<dd><p>Computes and returns the configuration options available for <i class="arg">obj</i>, to be consumed as method-parameter specification by <b class="method">configure</b>.</p></dd>
</dl></dd>
<dt><b class="cmd">property</b></dt>
<dd><dl class="definitions">
<dt><a name="32"><i class="arg">obj</i> <b class="method">object property</b> <span class="opt">?<b class="option">-accessor</b> <b class="const">public</b> | <b class="const">protected</b> | <b class="const">private</b>?</span> <span class="opt">?<b class="option">-configurable</b> <i class="arg">trueFalse</i>?</span> <span class="opt">?<b class="option">-incremental</b>?</span> <span class="opt">?<b class="option">-class</b> <i class="arg">className</i>?</span> <span class="opt">?<b class="option">-nocomplain</b>?</span> <i class="arg">spec</i> <span class="opt">?<i class="arg">initBlock</i>?</span></a></dt>
<dd><p>Defines a property for the scope of the object. The <i class="arg">spec</i> provides
the property specification as a <b class="cmd">list</b> holding at least one
element or, maximum, two elements:
<i class="arg">propertyName</i><span class="opt">?<b class="const">:</b><i class="arg">typeSpec</i>?</span> <span class="opt">?<i class="arg">defaultValue</i>?</span>. The <i class="arg">propertyName</i> is also used as to form the names of the getter/setter methods,
if requested (see <b class="option">-accessor</b>). It
is, optionally, equipped with a <i class="arg">typeSpec</i> following a colon
delimiter which specifies a value checker for the values
which become assigned to the property. The second, optional element
sets a <i class="arg">defaultValue</i> for this property.</p>
<p>If <b class="option">-accessor</b> is set, a property will provide for
a pair of getter and setter methods:</p>
<dl class="definitions">
<dt><i class="arg">obj</i> <i class="arg">propertyName</i> <b class="method">set</b> <i class="arg">value</i></dt>
<dd><p>Sets the property <i class="arg">propertyName</i> to <i class="arg">value</i>.</p></dd>
<dt><i class="arg">obj</i> <i class="arg">propertyName</i> <b class="method">get</b></dt>
<dd><p>Returns the current value of property <i class="arg">propertyName</i>.</p></dd>
<dt><i class="arg">obj</i> <i class="arg">propertyName</i> <b class="method">unset</b></dt>
<dd><p>Removes the value store of <i class="arg">propertyName</i> (e.g., an object variable), if existing.</p></dd>
</dl>
<p>The option value passed along <b class="option">-accessor</b> sets the level of
call protection for the generated getter and setter methods: <b class="const">public</b>,
<b class="const">protected</b>, or <b class="const">private</b>. By default, no getter and setter
methods are created.</p>
<p>Turning on the switch <b class="option">-incremental</b> provides a refined
setter interface to the value managed by the property. First,
setting <b class="option">-incremental</b> implies requesting <b class="option">-accessor</b>
(set to <b class="const">public</b> by default, if not specified
explicitly). Second, the managed value will be considered a valid Tcl
list. A multiplicity of <b class="const">1..*</b> is set by default, if not
specified explicitly as part of <i class="arg">spec</i>. Third, to
manage this list value element-wise (<em>incrementally</em>), two
additional setter methods become available:</p>
<dl class="definitions">
<dt><i class="arg">obj</i> <i class="arg">propertyName</i> <b class="method">add</b> <i class="arg">element</i> <span class="opt">?<i class="arg">index</i>?</span></dt>
<dd><p>Adding <i class="arg">element</i> to the managed list value, at the list position given by <i class="arg">index</i> (by default: 0).</p></dd>
<dt><i class="arg">obj</i> <i class="arg">propertyName</i> <b class="method">delete</b> <i class="arg">elementPattern</i></dt>
<dd><p>Removing one or multiple elements from the managed list value which match <i class="arg">elementPattern</i>. <i class="arg">elementPattern</i> can contain matching characters (see <b class="cmd">string match</b>).</p></dd>
</dl>
<p>By setting <b class="option">-configurable</b> to <b class="const">true</b> (the default), the
property can be accessed and modified through <b class="method">cget</b> and
<b class="method">configure</b>, respectively. If <b class="const">false</b>, no configuration option
will become available via <b class="method">cget</b> and <b class="method">configure</b>.</p>
<p>If neither <b class="option">-accessor</b> nor <b class="option">-configurable</b> are
requested, the value managed by the property will have to be accessed
and modified directly. If the property manages an object variable, its
value will be readable and writable using <b class="cmd">set</b> and <b class="method">eval</b>.</p>
<p>A property becomes implemented by a slot object under any of the following conditions:</p>
<ul class="itemized">
<li><p><b class="option">-configurable</b> equals <b class="const">true</b> (by default).</p></li>
<li><p><b class="option">-accessor</b> is one of <b class="const">public</b>, <b class="const">protected</b>, or <b class="const">private</b>.</p></li>
<li><p><b class="option">-incremental</b> is turned on.</p></li>
<li><p><i class="arg">initBlock</i> is a non-empty string.</p></li>
</ul>
<p>Assuming default settings, every property is realized by a
slot object.</p>
<p>Provided a slot object managing the property is to be
created, a custom class <i class="arg">className</i> from which this slot object is
to be instantiated can be set using <b class="option">-class</b>. The
default value is <b class="cmd">::nx::VariableSlot</b>.</p>
<p>The last argument <i class="arg">initBlock</i> accepts an optional Tcl script which is passed into
the initialization procedure (see <b class="method">configure</b>) of the property's slot object. See
also <span class="sectref"><a href="#section1"><i class="arg">initBlock</i> for <b class="method">create</b> and <b class="method">new</b></a></span>.</p>
<p>By default, the property will ascertain that no (potentially)
pre-existing and equally named object variable will be overwritten
when defining the property. In case of a conflict, an error exception
is thrown:</p>
<pre class="example">
% Object create obj { set :x 1 }
::obj
% ::obj object property {x 2}
object ::obj has already an instance variable named 'x'
</pre>
<p>If the switch <b class="option">-nocomplain</b> is on, this check is omitted (continuing the above example):</p>
<pre class="example">
% ::obj object property -nocomplain {x 2}
% ::obj eval {set :x}
2
</pre>
</dd>
</dl></dd>
<dt><b class="cmd">require</b></dt>
<dd><dl class="definitions">
<dt><a name="33"><i class="arg">obj</i> <b class="method">require namespace</b></a></dt>
<dd><p>Create a Tcl namespace named after the object <i class="arg">obj</i>. All object
variables become available as namespace variables.</p></dd>
<dt><a name="34"><i class="arg">obj</i> <b class="method">require</b> <span class="opt">?<b class="method">public</b> | <b class="method">protected</b> | <b class="method">private</b>?</span> <b class="method">object method</b> <i class="arg">methodName</i></a></dt>
<dd><p>Attempts to register a method definition made available using <b class="cmd">::nsf::method::provide</b> under
the name <i class="arg">methodName</i> with <i class="arg">obj</i> . The registered
method is subjected to default call protection (<b class="const">protected</b>), if
not set explicitly.</p></dd>
</dl></dd>
<dt><b class="cmd">unknown</b></dt>
<dd><dl class="definitions">
<dt><a name="35"><i class="arg">obj</i> <b class="method">unknown</b> <i class="arg">unknownMethodName</i> <span class="opt">?<i class="arg">arg</i> ...?</span></a></dt>
<dd><p>This method is called implicitly whenever an unknown method is invoked.
<i class="arg">unknownMethodName</i> indicates the unresolvable method name,
followed by the remainder of the original argument vector as a number
of <i class="arg">arg</i> of the indirected method invocation.</p></dd>
</dl></dd>
<dt><b class="cmd">variable</b></dt>
<dd><dl class="definitions">
<dt><a name="36"><i class="arg">obj</i> <b class="method">object variable</b> <span class="opt">?<b class="option">-accessor</b> <b class="const">public</b> | <b class="const">protected</b> | <b class="const">private</b>?</span> <span class="opt">?<b class="option">-incremental</b>?</span> <span class="opt">?<b class="option">-class</b> <i class="arg">className</i>?</span> <span class="opt">?<b class="option">-configurable</b> <i class="arg">trueFalse</i>?</span> <span class="opt">?<b class="option">-initblock</b> <i class="arg">script</i>?</span> <span class="opt">?<b class="option">-nocomplain</b>?</span> <i class="arg">spec</i> <span class="opt">?<i class="arg">defaultValue</i>?</span></a></dt>
<dd><p>Defines a variable for the scope of the object. The <i class="arg">spec</i> provides
the variable specification: <i class="arg">variableName</i><span class="opt">?<b class="const">:</b><i class="arg">typeSpec</i>?</span>. The
<i class="arg">variableName</i> will be used to name the underlying Tcl variable
and the getter/setter methods, if requested (see <b class="option">-accessor</b>).
<i class="arg">spec</i> is optionally equipped with a <i class="arg">typeSpec</i> following a colon
delimiter which specifies a value checker for the values
managed by the variable. Optionally, a <em>defaultValue</em> can
be defined.</p>
<p>If <b class="option">-accessor</b> is set explicitly, a variable will provide for a pair of
getter and setter methods:</p>
<dl class="definitions">
<dt><i class="arg">obj</i> <i class="arg">variableName</i> <b class="method">set</b> <i class="arg">varValue</i></dt>
<dd><p>Sets <i class="arg">variableName</i> to <i class="arg">varValue</i>.</p></dd>
<dt><i class="arg">obj</i> <i class="arg">variableName</i> <b class="method">get</b></dt>
<dd><p>Returns the current value of <i class="arg">variableName</i>.</p></dd>
<dt><i class="arg">obj</i> <i class="arg">variableName</i> <b class="method">unset</b></dt>
<dd><p>Removes <i class="arg">variableName</i>, if existing, underlying the property.</p></dd>
</dl>
<p>The option value passed along <b class="option">-accessor</b> sets the level of
call protection for the getter and setter methods: <b class="const">public</b>,
<b class="const">protected</b>, or <b class="const">private</b>. By default, no getter and setter
methods are created.</p>
<p>Turning on the switch <b class="option">-incremental</b> provides a refined
setter interface to the value managed by the variable. First,
setting <b class="option">-incremental</b> implies requesting <b class="option">-accessor</b>
(<b class="const">public</b> by default, if not specified
explicitly). Second, the managed value will be considered a valid Tcl
list. A multiplicity of <b class="const">1..*</b> is set by default, if not
specified explicitly as part of <i class="arg">spec</i> (see above). Third, to
manage this list value element-wise (<em>incrementally</em>), two
additional setter operations become available:</p>
<dl class="definitions">
<dt><i class="arg">obj</i> <i class="arg">variableName</i> <b class="method">add</b> <i class="arg">element</i> <span class="opt">?<i class="arg">index</i>?</span></dt>
<dd><p>Adding <i class="arg">element</i> to the managed list value, at the list position given by <i class="arg">index</i> (by default: 0).</p></dd>
<dt><i class="arg">obj</i> <i class="arg">variableName</i> <b class="method">delete</b> <i class="arg">elementPattern</i></dt>
<dd><p>Removing one or multiple elements from the managed list value which
match <i class="arg">elementPattern</i>. <i class="arg">elementPattern</i> can contain matching
characters (see <b class="cmd">string match</b>).</p></dd>
</dl>
<p>By setting <b class="option">-configurable</b> to <b class="const">true</b>, the variable can be
accessed and modified via <b class="method">cget</b> and <b class="method">configure</b>,
respectively. If <b class="const">false</b> (the default), the interface based on <b class="method">cget</b> and
<b class="method">configure</b> will not become available. In this case, and provided that
<b class="option">-accessor</b> is set, the variable can be accessed and modified via
the getter/setter methods. Alternatively, the underlying Tcl variable, which
is represented by the variable, can always be accessed and modified
directly, e.g., using <b class="method">eval</b>. By default, <b class="option">-configurable</b> is
<b class="const">false</b>.</p>
<p>A variable becomes implemented by a slot object under any of the following conditions:</p>
<ul class="itemized">
<li><p><b class="option">-configurable</b> equals <b class="const">true</b>.</p></li>
<li><p><b class="option">-accessor</b> is one of <b class="const">public</b>, <b class="const">protected</b>, or <b class="const">private</b>.</p></li>
<li><p><b class="option">-incremental</b> is turned on.</p></li>
<li><p><b class="option">-initblock</b> is a non-empty string.</p></li>
</ul>
<p>Provided a slot object managing the variable is to be
created, a custom class <i class="arg">className</i> from which this slot object is
to be instantiated can be set using <b class="option">-class</b>. The
default value is <b class="cmd">::nx::VariableSlot</b>.</p>
<p>Using <b class="option">-initblock</b>, an optional Tcl <i class="arg">script</i> can be defined which becomes passed into
the initialization procedure (see <b class="method">configure</b>) of the variable's slot object. See
also <span class="sectref"><a href="#section1"><i class="arg">initBlock</i> for <b class="method">create</b> and <b class="method">new</b></a></span>.</p>
<p>By default, the variable will ascertain that a
pre-existing and equally named object variable will not be overwritten
when defining the variable. In case of a conflict, an error exception
is thrown:</p>
<pre class="example">
% Object create obj { set :x 1 }
::obj
% ::obj object variable x 2
object ::obj has already an instance variable named 'x'
</pre>
<p>If the switch <b class="option">-nocomplain</b> is on, this check is omitted (continuing the above example):</p>
<pre class="example">
% ::obj object variable -nocomplain x 2
% ::obj eval {set :x}
2
</pre>
</dd>
</dl></dd>
</dl>
</div>
<div id="section4" class="section"><h2><a name="section4">Object Self-Reference</a></h2>
<p>Objects are naturally recursive, with methods of an object <b class="const">::obj</b>
frequently invoking other methods in the same object <b class="const">::obj</b> and
accessing <b class="const">::obj</b>'s object variables. To represent these
self-references effectively in method bodies, and depending on the
usage scenario, NX offers two alternative notations for self-references: one based on a
special-purpose syntax token ("colon prefix"), the other based on the
command <b class="cmd">nx::current</b>.</p>
<p>Both, the colon-prefix notation and
<b class="cmd">nx::current</b>, may be used only in method bodies and scripts
passed to <b class="method">eval</b>. If they appear anywhere else, an error will be
reported.
There are three main use cases for self-references:</p>
<ol class="enumerated">
<li><p>As a <em>placeholder</em> for the currently active object, <b class="cmd">nx::current</b>
can be used to retrieve the object name.</p></li>
<li><p>Reading and writing <em>object variables</em> directly (i.e. without getter/setter methods in place) require the use
of variable names carrying the prefix <b class="const">:</b> ("colon-prefix
notation"). Internally, colon-prefixed variable names are processed
using Tcl's variable resolvers. Alternatively, one can provide for getter/setter methods for object variables (see <b class="method">property</b> and <b class="method">variable</b>).</p></li>
<li><p><em>Self-referential method calls</em> can be defined via
prefixing (<b class="const">:</b>) the method names or, alternatively, via <b class="cmd">nx::current</b>. Internally,
colon-prefixed method names are processed using Tcl's command
resolvers. The colon-prefix notation is recommended, also because it
has a (slight) performance advantage over <b class="cmd">nx::current</b> which
requires two rather than one command evaluation per method call.</p></li>
</ol>
<p>See the following listing for some examples corresponding to use cases 1--3:</p>
<pre class="example">
Object create ::obj {
puts [current]; # 1) print name of currently active object ('::obj')
set :x 1; :object variable y 2; # 2) object variables
:public object method print {} {
set z 3; # 2.a) method-local variable
puts ${:x}-${:y}-$z; # 2.b) variable substitution using '$' and ':'
puts [set :x]-[set :y]-[set z]; # 2.c) reading variables using 'set'
set :x 1; incr :y; # 2.d) writing variables using 'set', 'incr', ...
}
:public object method show {} {
:print; # 3.a) self-referential method call using ':'
[current] print; # 3.b) self-referential method call using 'nx::current'
[current object] print; # 3.c) self-referential method call using 'nx::current object'
}
:show
}</pre>
</div>
<div id="copyright" class="section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright © 2014 Stefan Sobernig <stefan.sobernig@wu.ac.at>, Gustaf Neumann <gustaf.neumann@wu.ac.at>; available under the Creative Commons Attribution 3.0 Austria license (CC BY 3.0 AT).</p>
</div>
</div></body></html>
|