Index: ChangeLog-2.0.0-2.1.0.log =================================================================== diff -u -r2a955681817e4db4776d7ae904babe8053c5ad74 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- ChangeLog-2.0.0-2.1.0.log (.../ChangeLog-2.0.0-2.1.0.log) (revision 2a955681817e4db4776d7ae904babe8053c5ad74) +++ ChangeLog-2.0.0-2.1.0.log (.../ChangeLog-2.0.0-2.1.0.log) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -416,11 +416,10 @@ * nsf.c: (ParamOptionParse): 'virtualobjectargs' and 'virtualclassargs' defaulted to ConvertViaCmd when parsed from Tcl spec; explicitly - set ConvertToNothing to match the intended semantics and to avoid + set ConvertToNothing to match the intended semantics and to avoid false warnings (e.g., missing type=virtualobjectargs type checker). [03b838a] - (NsfParameterInfoCmd): Correct two typos in in-code - comment. [6d563e2] + (NsfParameterInfoCmd): Correct two typos in code comment. [6d563e2] 2016-10-02 Stefan Sobernig <stefan.sobernig@wu.ac.at> Index: ChangeLog-2.0b3-2.0b5.log =================================================================== diff -u -r9aa53ef688133d4af8bdff20f8913fe34f8a44ad -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- ChangeLog-2.0b3-2.0b5.log (.../ChangeLog-2.0b3-2.0b5.log) (revision 9aa53ef688133d4af8bdff20f8913fe34f8a44ad) +++ ChangeLog-2.0b3-2.0b5.log (.../ChangeLog-2.0b3-2.0b5.log) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -117,7 +117,7 @@ we might wish a more general solution (see comment for futures releases) - - when creation with an required configure parameter failed, delete the + - when creation with a required configure parameter failed, delete the half-baked object to avoid confusing states. - nx::test: show msg at start of test file Index: ChangeLog-2.0b5-2.0.0.log =================================================================== diff -u -rb5c493afe905b1bafc17697ed3ce01d1662c77b3 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- ChangeLog-2.0b5-2.0.0.log (.../ChangeLog-2.0b5-2.0.0.log) (revision b5c493afe905b1bafc17697ed3ce01d1662c77b3) +++ ChangeLog-2.0b5-2.0.0.log (.../ChangeLog-2.0b5-2.0.0.log) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -529,7 +529,7 @@ function DependentSubClasses(). With the new implementation, NsfParameterCacheClassInvalidateCmd() is as efficient as before without to MostGeneralSuperclass optimization (but being complete now) when - working on the root classes (an more efficient on subclasses). + working on the root classes (and more efficient on subclasses). 2014-06-04 Gustaf Neumann <neumann@wu-wien.ac.at> Index: ChangeLog-2.2.0-2.3.0.log =================================================================== diff -u -r63fa317128555211b749beedd51f32e82af6b340 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- ChangeLog-2.2.0-2.3.0.log (.../ChangeLog-2.2.0-2.3.0.log) (revision 63fa317128555211b749beedd51f32e82af6b340) +++ ChangeLog-2.2.0-2.3.0.log (.../ChangeLog-2.2.0-2.3.0.log) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -279,7 +279,7 @@ * nsf.c, speedtest.xotcl: Improved handling of object property autonamed [c86c0775] * serializer.tcl: Preserve overriding slot accessor methods - defined via XOTcl instprocs during serialisation. [542f9ead] + defined via XOTcl instprocs during serialization. [542f9ead] 2019-03-12 Stefan Sobernig <stefan.sobernig@wu.ac.at> @@ -422,7 +422,7 @@ 2018-10-24 Stefan Sobernig <stefan.sobernig@wu.ac.at> * disposition.test, parameters.test: Adjust tests to reflect the - changed representational behaviour for numerics (int, wide) according + changed representational behavior for numerics (int, wide) according to TIP 514 (now in Tcl 8.7a2+). [fca63858] 2018-10-23 Gustaf Neumann <neumann@wu-wien.ac.at> Index: doc/Announce2.3.0 =================================================================== diff -u -rfc11b2380eef48346410636908936e9468c74807 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- doc/Announce2.3.0 (.../Announce2.3.0) (revision fc11b2380eef48346410636908936e9468c74807) +++ doc/Announce2.3.0 (.../Announce2.3.0) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -29,7 +29,7 @@ 0 This is to avoid having to rely on pattern sniffing of the - command names. In addition, the propery is now set early enough, + command names. In addition, the property is now set early enough, right after allocating the NSF object, to test for the autonaming condition from within the creation procedure (ttrace). @@ -83,9 +83,9 @@ - XOTcl: - * Improved compatibility of XOTcl2 with XOTcl1 behaviour + * Improved compatibility of XOTcl2 with XOTcl1 behavior for volatile objects (see "volatile reform" above). - * Improved compatibility of XOTcl2 with XOTcl1 behaviour for + * Improved compatibility of XOTcl2 with XOTcl1 behavior for uplevel/upvar from within methods (see "uplevel/ upvar reform" above). Index: doc/next-migration.html =================================================================== diff -u -r6cbeef2d45ae090cf57de7703e0b480125e277b1 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- doc/next-migration.html (.../next-migration.html) (revision 6cbeef2d45ae090cf57de7703e0b480125e277b1) +++ doc/next-migration.html (.../next-migration.html) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -1,6488 +1,6488 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" - "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> -<head> -<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> -<meta name="generator" content="AsciiDoc 8.6.9" /> -<title>Migration Guide for the Next Scripting Language</title> -<style type="text/css"> -/* Shared CSS for AsciiDoc xhtml11 and html5 backends */ - -/* Default font. */ -body { - font-family: Georgia,serif; -} - -/* Title font. */ -h1, h2, h3, h4, h5, h6, -div.title, caption.title, -thead, p.table.header, -#toctitle, -#author, #revnumber, #revdate, #revremark, -#footer { - font-family: Arial,Helvetica,sans-serif; -} - -body { - margin: 1em 5% 1em 5%; -} - -a { - color: blue; - text-decoration: underline; -} -a:visited { - color: fuchsia; -} - -em { - font-style: italic; - color: navy; -} - -strong { - font-weight: bold; - color: #083194; -} - -h1, h2, h3, h4, h5, h6 { - color: #527bbd; - margin-top: 1.2em; - margin-bottom: 0.5em; - line-height: 1.3; -} - -h1, h2, h3 { - border-bottom: 2px solid silver; -} -h2 { - padding-top: 0.5em; -} -h3 { - float: left; -} -h3 + * { - clear: left; -} -h5 { - font-size: 1.0em; -} - -div.sectionbody { - margin-left: 0; -} - -hr { - border: 1px solid silver; -} - -p { - margin-top: 0.5em; - margin-bottom: 0.5em; -} - -ul, ol, li > p { - margin-top: 0; -} -ul > li { color: #aaa; } -ul > li > * { color: black; } - -.monospaced, code, pre { - font-family: "Courier New", Courier, monospace; - font-size: inherit; - color: navy; - padding: 0; - margin: 0; -} -pre { - white-space: pre-wrap; -} - -#author { - color: #527bbd; - font-weight: bold; - font-size: 1.1em; -} -#email { -} -#revnumber, #revdate, #revremark { -} - -#footer { - font-size: small; - border-top: 2px solid silver; - padding-top: 0.5em; - margin-top: 4.0em; -} -#footer-text { - float: left; - padding-bottom: 0.5em; -} -#footer-badges { - float: right; - padding-bottom: 0.5em; -} - -#preamble { - margin-top: 1.5em; - margin-bottom: 1.5em; -} -div.imageblock, div.exampleblock, div.verseblock, -div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, -div.admonitionblock { - margin-top: 1.0em; - margin-bottom: 1.5em; -} -div.admonitionblock { - margin-top: 2.0em; - margin-bottom: 2.0em; - margin-right: 10%; - color: #606060; -} - -div.content { /* Block element content. */ - padding: 0; -} - -/* Block element titles. */ -div.title, caption.title { - color: #527bbd; - font-weight: bold; - text-align: left; - margin-top: 1.0em; - margin-bottom: 0.5em; -} -div.title + * { - margin-top: 0; -} - -td div.title:first-child { - margin-top: 0.0em; -} -div.content div.title:first-child { - margin-top: 0.0em; -} -div.content + div.title { - margin-top: 0.0em; -} - -div.sidebarblock > div.content { - background: #ffffee; - border: 1px solid #dddddd; - border-left: 4px solid #f0f0f0; - padding: 0.5em; -} - -div.listingblock > div.content { - border: 1px solid #dddddd; - border-left: 5px solid #f0f0f0; - background: #f8f8f8; - padding: 0.5em; -} - -div.quoteblock, div.verseblock { - padding-left: 1.0em; - margin-left: 1.0em; - margin-right: 10%; - border-left: 5px solid #f0f0f0; - color: #888; -} - -div.quoteblock > div.attribution { - padding-top: 0.5em; - text-align: right; -} - -div.verseblock > pre.content { - font-family: inherit; - font-size: inherit; -} -div.verseblock > div.attribution { - padding-top: 0.75em; - text-align: left; -} -/* DEPRECATED: Pre version 8.2.7 verse style literal block. */ -div.verseblock + div.attribution { - text-align: left; -} - -div.admonitionblock .icon { - vertical-align: top; - font-size: 1.1em; - font-weight: bold; - text-decoration: underline; - color: #527bbd; - padding-right: 0.5em; -} -div.admonitionblock td.content { - padding-left: 0.5em; - border-left: 3px solid #dddddd; -} - -div.exampleblock > div.content { - border-left: 3px solid #dddddd; - padding-left: 0.5em; -} - -div.imageblock div.content { padding-left: 0; } -span.image img { border-style: none; vertical-align: text-bottom; } -a.image:visited { color: white; } - -dl { - margin-top: 0.8em; - margin-bottom: 0.8em; -} -dt { - margin-top: 0.5em; - margin-bottom: 0; - font-style: normal; - color: navy; -} -dd > *:first-child { - margin-top: 0.1em; -} - -ul, ol { - list-style-position: outside; -} -ol.arabic { - list-style-type: decimal; -} -ol.loweralpha { - list-style-type: lower-alpha; -} -ol.upperalpha { - list-style-type: upper-alpha; -} -ol.lowerroman { - list-style-type: lower-roman; -} -ol.upperroman { - list-style-type: upper-roman; -} - -div.compact ul, div.compact ol, -div.compact p, div.compact p, -div.compact div, div.compact div { - margin-top: 0.1em; - margin-bottom: 0.1em; -} - -tfoot { - font-weight: bold; -} -td > div.verse { - white-space: pre; -} - -div.hdlist { - margin-top: 0.8em; - margin-bottom: 0.8em; -} -div.hdlist tr { - padding-bottom: 15px; -} -dt.hdlist1.strong, td.hdlist1.strong { - font-weight: bold; -} -td.hdlist1 { - vertical-align: top; - font-style: normal; - padding-right: 0.8em; - color: navy; -} -td.hdlist2 { - vertical-align: top; -} -div.hdlist.compact tr { - margin: 0; - padding-bottom: 0; -} - -.comment { - background: yellow; -} - -.footnote, .footnoteref { - font-size: 0.8em; -} - -span.footnote, span.footnoteref { - vertical-align: super; -} - -#footnotes { - margin: 20px 0 20px 0; - padding: 7px 0 0 0; -} - -#footnotes div.footnote { - margin: 0 0 5px 0; -} - -#footnotes hr { - border: none; - border-top: 1px solid silver; - height: 1px; - text-align: left; - margin-left: 0; - width: 20%; - min-width: 100px; -} - -div.colist td { - padding-right: 0.5em; - padding-bottom: 0.3em; - vertical-align: top; -} -div.colist td img { - margin-top: 0.3em; -} - -@media print { - #footer-badges { display: none; } -} - -#toc { - margin-bottom: 2.5em; -} - -#toctitle { - color: #527bbd; - font-size: 1.1em; - font-weight: bold; - margin-top: 1.0em; - margin-bottom: 0.1em; -} - -div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { - margin-top: 0; - margin-bottom: 0; -} -div.toclevel2 { - margin-left: 2em; - font-size: 0.9em; -} -div.toclevel3 { - margin-left: 4em; - font-size: 0.9em; -} -div.toclevel4 { - margin-left: 6em; - font-size: 0.9em; -} - -span.aqua { color: aqua; } -span.black { color: black; } -span.blue { color: blue; } -span.fuchsia { color: fuchsia; } -span.gray { color: gray; } -span.green { color: green; } -span.lime { color: lime; } -span.maroon { color: maroon; } -span.navy { color: navy; } -span.olive { color: olive; } -span.purple { color: purple; } -span.red { color: red; } -span.silver { color: silver; } -span.teal { color: teal; } -span.white { color: white; } -span.yellow { color: yellow; } - -span.aqua-background { background: aqua; } -span.black-background { background: black; } -span.blue-background { background: blue; } -span.fuchsia-background { background: fuchsia; } -span.gray-background { background: gray; } -span.green-background { background: green; } -span.lime-background { background: lime; } -span.maroon-background { background: maroon; } -span.navy-background { background: navy; } -span.olive-background { background: olive; } -span.purple-background { background: purple; } -span.red-background { background: red; } -span.silver-background { background: silver; } -span.teal-background { background: teal; } -span.white-background { background: white; } -span.yellow-background { background: yellow; } - -span.big { font-size: 2em; } -span.small { font-size: 0.6em; } - -span.underline { text-decoration: underline; } -span.overline { text-decoration: overline; } -span.line-through { text-decoration: line-through; } - -div.unbreakable { page-break-inside: avoid; } - - -/* - * xhtml11 specific - * - * */ - -div.tableblock { - margin-top: 1.0em; - margin-bottom: 1.5em; -} -div.tableblock > table { - border: 3px solid #527bbd; -} -thead, p.table.header { - font-weight: bold; - color: #527bbd; -} -p.table { - margin-top: 0; -} -/* Because the table frame attribute is overriden by CSS in most browsers. */ -div.tableblock > table[frame="void"] { - border-style: none; -} -div.tableblock > table[frame="hsides"] { - border-left-style: none; - border-right-style: none; -} -div.tableblock > table[frame="vsides"] { - border-top-style: none; - border-bottom-style: none; -} - - -/* - * html5 specific - * - * */ - -table.tableblock { - margin-top: 1.0em; - margin-bottom: 1.5em; -} -thead, p.tableblock.header { - font-weight: bold; - color: #527bbd; -} -p.tableblock { - margin-top: 0; -} -table.tableblock { - border-width: 3px; - border-spacing: 0px; - border-style: solid; - border-color: #527bbd; - border-collapse: collapse; -} -th.tableblock, td.tableblock { - border-width: 1px; - padding: 4px; - border-style: solid; - border-color: #527bbd; -} - -table.tableblock.frame-topbot { - border-left-style: hidden; - border-right-style: hidden; -} -table.tableblock.frame-sides { - border-top-style: hidden; - border-bottom-style: hidden; -} -table.tableblock.frame-none { - border-style: hidden; -} - -th.tableblock.halign-left, td.tableblock.halign-left { - text-align: left; -} -th.tableblock.halign-center, td.tableblock.halign-center { - text-align: center; -} -th.tableblock.halign-right, td.tableblock.halign-right { - text-align: right; -} - -th.tableblock.valign-top, td.tableblock.valign-top { - vertical-align: top; -} -th.tableblock.valign-middle, td.tableblock.valign-middle { - vertical-align: middle; -} -th.tableblock.valign-bottom, td.tableblock.valign-bottom { - vertical-align: bottom; -} - - -/* - * manpage specific - * - * */ - -body.manpage h1 { - padding-top: 0.5em; - padding-bottom: 0.5em; - border-top: 2px solid silver; - border-bottom: 2px solid silver; -} -body.manpage h2 { - border-style: none; -} -body.manpage div.sectionbody { - margin-left: 3em; -} - -@media print { - body.manpage div#toc { display: none; } -} - - -</style> -<script type="text/javascript"> -/*<+'])'); - // Function that scans the DOM tree for header elements (the DOM2 - // nodeIterator API would be a better technique but not supported by all - // browsers). - var iterate = function (el) { - for (var i = el.firstChild; i != null; i = i.nextSibling) { - if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { - var mo = re.exec(i.tagName); - if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { - result[result.length] = new TocEntry(i, getText(i), mo[1]-1); - } - iterate(i); - } - } - } - iterate(el); - return result; - } - - var toc = document.getElementById("toc"); - if (!toc) { - return; - } - - // Delete existing TOC entries in case we're reloading the TOC. - var tocEntriesToRemove = []; - var i; - for (i = 0; i < toc.childNodes.length; i++) { - var entry = toc.childNodes[i]; - if (entry.nodeName.toLowerCase() == 'div' - && entry.getAttribute("class") - && entry.getAttribute("class").match(/^toclevel/)) - tocEntriesToRemove.push(entry); - } - for (i = 0; i < tocEntriesToRemove.length; i++) { - toc.removeChild(tocEntriesToRemove[i]); - } - - // Rebuild TOC entries. - var entries = tocEntries(document.getElementById("content"), toclevels); - for (var i = 0; i < entries.length; ++i) { - var entry = entries[i]; - if (entry.element.id == "") - entry.element.id = "_toc_" + i; - var a = document.createElement("a"); - a.href = "#" + entry.element.id; - a.appendChild(document.createTextNode(entry.text)); - var div = document.createElement("div"); - div.appendChild(a); - div.className = "toclevel" + entry.toclevel; - toc.appendChild(div); - } - if (entries.length == 0) - toc.parentNode.removeChild(toc); -}, - - -///////////////////////////////////////////////////////////////////// -// Footnotes generator -///////////////////////////////////////////////////////////////////// - -/* Based on footnote generation code from: - * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html - */ - -footnotes: function () { - // Delete existing footnote entries in case we're reloading the footnodes. - var i; - var noteholder = document.getElementById("footnotes"); - if (!noteholder) { - return; - } - var entriesToRemove = []; - for (i = 0; i < noteholder.childNodes.length; i++) { - var entry = noteholder.childNodes[i]; - if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") - entriesToRemove.push(entry); - } - for (i = 0; i < entriesToRemove.length; i++) { - noteholder.removeChild(entriesToRemove[i]); - } - - // Rebuild footnote entries. - var cont = document.getElementById("content"); - var spans = cont.getElementsByTagName("span"); - var refs = {}; - var n = 0; - for (i=0; i<spans.length; i++) { - if (spans[i].className == "footnote") { - n++; - var note = spans[i].getAttribute("data-note"); - if (!note) { - // Use [\s\S] in place of . so multi-line matches work. - // Because JavaScript has no s (dotall) regex flag. - note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1]; - spans[i].innerHTML = - "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n + - "' title='View footnote' class='footnote'>" + n + "</a>]"; - spans[i].setAttribute("data-note", note); - } - noteholder.innerHTML += - "<div class='footnote' id='_footnote_" + n + "'>" + - "<a href='#_footnoteref_" + n + "' title='Return to text'>" + - n + "</a>. " + note + "</div>"; - var id =spans[i].getAttribute("id"); - if (id != null) refs["#"+id] = n; - } - } - if (n == 0) - noteholder.parentNode.removeChild(noteholder); - else { - // Process footnoterefs. - for (i=0; i<spans.length; i++) { - if (spans[i].className == "footnoteref") { - var href = spans[i].getElementsByTagName("a")[0].getAttribute("href"); - href = href.match(/#.*/)[0]; // Because IE return full URL. - n = refs[href]; - spans[i].innerHTML = - "[<a href='#_footnote_" + n + - "' title='View footnote' class='footnote'>" + n + "</a>]"; - } - } - } -}, - -install: function(toclevels) { - var timerId; - - function reinstall() { - asciidoc.footnotes(); - if (toclevels) { - asciidoc.toc(toclevels); - } - } - - function reinstallAndRemoveTimer() { - clearInterval(timerId); - reinstall(); - } - - timerId = setInterval(reinstall, 500); - if (document.addEventListener) - document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); - else - window.onload = reinstallAndRemoveTimer; -} - -} -asciidoc.install(3); -/*]]>*/ -</script> -</head> -<body class="article"> -<div id="header"> -<h1>Migration Guide for the Next Scripting Language</h1> -<span id="author">Gustaf Neumann</span><br /> -<span id="email"><code><<a href="mailto:neumann@wu-wien.ac.at">neumann@wu-wien.ac.at</a>></code></span><br /> -<span id="revnumber">version 2.2.0,</span> -<span id="revdate">September 2018</span> -<br /><span id="revremark"></span> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> +<head> +<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> +<meta name="generator" content="AsciiDoc 8.6.9" /> +<title>Migration Guide for the Next Scripting Language</title> +<style type="text/css"> +/* Shared CSS for AsciiDoc xhtml11 and html5 backends */ + +/* Default font. */ +body { + font-family: Georgia,serif; +} + +/* Title font. */ +h1, h2, h3, h4, h5, h6, +div.title, caption.title, +thead, p.table.header, +#toctitle, +#author, #revnumber, #revdate, #revremark, +#footer { + font-family: Arial,Helvetica,sans-serif; +} + +body { + margin: 1em 5% 1em 5%; +} + +a { + color: blue; + text-decoration: underline; +} +a:visited { + color: fuchsia; +} + +em { + font-style: italic; + color: navy; +} + +strong { + font-weight: bold; + color: #083194; +} + +h1, h2, h3, h4, h5, h6 { + color: #527bbd; + margin-top: 1.2em; + margin-bottom: 0.5em; + line-height: 1.3; +} + +h1, h2, h3 { + border-bottom: 2px solid silver; +} +h2 { + padding-top: 0.5em; +} +h3 { + float: left; +} +h3 + * { + clear: left; +} +h5 { + font-size: 1.0em; +} + +div.sectionbody { + margin-left: 0; +} + +hr { + border: 1px solid silver; +} + +p { + margin-top: 0.5em; + margin-bottom: 0.5em; +} + +ul, ol, li > p { + margin-top: 0; +} +ul > li { color: #aaa; } +ul > li > * { color: black; } + +.monospaced, code, pre { + font-family: "Courier New", Courier, monospace; + font-size: inherit; + color: navy; + padding: 0; + margin: 0; +} +pre { + white-space: pre-wrap; +} + +#author { + color: #527bbd; + font-weight: bold; + font-size: 1.1em; +} +#email { +} +#revnumber, #revdate, #revremark { +} + +#footer { + font-size: small; + border-top: 2px solid silver; + padding-top: 0.5em; + margin-top: 4.0em; +} +#footer-text { + float: left; + padding-bottom: 0.5em; +} +#footer-badges { + float: right; + padding-bottom: 0.5em; +} + +#preamble { + margin-top: 1.5em; + margin-bottom: 1.5em; +} +div.imageblock, div.exampleblock, div.verseblock, +div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, +div.admonitionblock { + margin-top: 1.0em; + margin-bottom: 1.5em; +} +div.admonitionblock { + margin-top: 2.0em; + margin-bottom: 2.0em; + margin-right: 10%; + color: #606060; +} + +div.content { /* Block element content. */ + padding: 0; +} + +/* Block element titles. */ +div.title, caption.title { + color: #527bbd; + font-weight: bold; + text-align: left; + margin-top: 1.0em; + margin-bottom: 0.5em; +} +div.title + * { + margin-top: 0; +} + +td div.title:first-child { + margin-top: 0.0em; +} +div.content div.title:first-child { + margin-top: 0.0em; +} +div.content + div.title { + margin-top: 0.0em; +} + +div.sidebarblock > div.content { + background: #ffffee; + border: 1px solid #dddddd; + border-left: 4px solid #f0f0f0; + padding: 0.5em; +} + +div.listingblock > div.content { + border: 1px solid #dddddd; + border-left: 5px solid #f0f0f0; + background: #f8f8f8; + padding: 0.5em; +} + +div.quoteblock, div.verseblock { + padding-left: 1.0em; + margin-left: 1.0em; + margin-right: 10%; + border-left: 5px solid #f0f0f0; + color: #888; +} + +div.quoteblock > div.attribution { + padding-top: 0.5em; + text-align: right; +} + +div.verseblock > pre.content { + font-family: inherit; + font-size: inherit; +} +div.verseblock > div.attribution { + padding-top: 0.75em; + text-align: left; +} +/* DEPRECATED: Pre version 8.2.7 verse style literal block. */ +div.verseblock + div.attribution { + text-align: left; +} + +div.admonitionblock .icon { + vertical-align: top; + font-size: 1.1em; + font-weight: bold; + text-decoration: underline; + color: #527bbd; + padding-right: 0.5em; +} +div.admonitionblock td.content { + padding-left: 0.5em; + border-left: 3px solid #dddddd; +} + +div.exampleblock > div.content { + border-left: 3px solid #dddddd; + padding-left: 0.5em; +} + +div.imageblock div.content { padding-left: 0; } +span.image img { border-style: none; vertical-align: text-bottom; } +a.image:visited { color: white; } + +dl { + margin-top: 0.8em; + margin-bottom: 0.8em; +} +dt { + margin-top: 0.5em; + margin-bottom: 0; + font-style: normal; + color: navy; +} +dd > *:first-child { + margin-top: 0.1em; +} + +ul, ol { + list-style-position: outside; +} +ol.arabic { + list-style-type: decimal; +} +ol.loweralpha { + list-style-type: lower-alpha; +} +ol.upperalpha { + list-style-type: upper-alpha; +} +ol.lowerroman { + list-style-type: lower-roman; +} +ol.upperroman { + list-style-type: upper-roman; +} + +div.compact ul, div.compact ol, +div.compact p, div.compact p, +div.compact div, div.compact div { + margin-top: 0.1em; + margin-bottom: 0.1em; +} + +tfoot { + font-weight: bold; +} +td > div.verse { + white-space: pre; +} + +div.hdlist { + margin-top: 0.8em; + margin-bottom: 0.8em; +} +div.hdlist tr { + padding-bottom: 15px; +} +dt.hdlist1.strong, td.hdlist1.strong { + font-weight: bold; +} +td.hdlist1 { + vertical-align: top; + font-style: normal; + padding-right: 0.8em; + color: navy; +} +td.hdlist2 { + vertical-align: top; +} +div.hdlist.compact tr { + margin: 0; + padding-bottom: 0; +} + +.comment { + background: yellow; +} + +.footnote, .footnoteref { + font-size: 0.8em; +} + +span.footnote, span.footnoteref { + vertical-align: super; +} + +#footnotes { + margin: 20px 0 20px 0; + padding: 7px 0 0 0; +} + +#footnotes div.footnote { + margin: 0 0 5px 0; +} + +#footnotes hr { + border: none; + border-top: 1px solid silver; + height: 1px; + text-align: left; + margin-left: 0; + width: 20%; + min-width: 100px; +} + +div.colist td { + padding-right: 0.5em; + padding-bottom: 0.3em; + vertical-align: top; +} +div.colist td img { + margin-top: 0.3em; +} + +@media print { + #footer-badges { display: none; } +} + +#toc { + margin-bottom: 2.5em; +} + +#toctitle { + color: #527bbd; + font-size: 1.1em; + font-weight: bold; + margin-top: 1.0em; + margin-bottom: 0.1em; +} + +div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { + margin-top: 0; + margin-bottom: 0; +} +div.toclevel2 { + margin-left: 2em; + font-size: 0.9em; +} +div.toclevel3 { + margin-left: 4em; + font-size: 0.9em; +} +div.toclevel4 { + margin-left: 6em; + font-size: 0.9em; +} + +span.aqua { color: aqua; } +span.black { color: black; } +span.blue { color: blue; } +span.fuchsia { color: fuchsia; } +span.gray { color: gray; } +span.green { color: green; } +span.lime { color: lime; } +span.maroon { color: maroon; } +span.navy { color: navy; } +span.olive { color: olive; } +span.purple { color: purple; } +span.red { color: red; } +span.silver { color: silver; } +span.teal { color: teal; } +span.white { color: white; } +span.yellow { color: yellow; } + +span.aqua-background { background: aqua; } +span.black-background { background: black; } +span.blue-background { background: blue; } +span.fuchsia-background { background: fuchsia; } +span.gray-background { background: gray; } +span.green-background { background: green; } +span.lime-background { background: lime; } +span.maroon-background { background: maroon; } +span.navy-background { background: navy; } +span.olive-background { background: olive; } +span.purple-background { background: purple; } +span.red-background { background: red; } +span.silver-background { background: silver; } +span.teal-background { background: teal; } +span.white-background { background: white; } +span.yellow-background { background: yellow; } + +span.big { font-size: 2em; } +span.small { font-size: 0.6em; } + +span.underline { text-decoration: underline; } +span.overline { text-decoration: overline; } +span.line-through { text-decoration: line-through; } + +div.unbreakable { page-break-inside: avoid; } + + +/* + * xhtml11 specific + * + * */ + +div.tableblock { + margin-top: 1.0em; + margin-bottom: 1.5em; +} +div.tableblock > table { + border: 3px solid #527bbd; +} +thead, p.table.header { + font-weight: bold; + color: #527bbd; +} +p.table { + margin-top: 0; +} +/* Because the table frame attribute is overridden by CSS in most browsers. */ +div.tableblock > table[frame="void"] { + border-style: none; +} +div.tableblock > table[frame="hsides"] { + border-left-style: none; + border-right-style: none; +} +div.tableblock > table[frame="vsides"] { + border-top-style: none; + border-bottom-style: none; +} + + +/* + * html5 specific + * + * */ + +table.tableblock { + margin-top: 1.0em; + margin-bottom: 1.5em; +} +thead, p.tableblock.header { + font-weight: bold; + color: #527bbd; +} +p.tableblock { + margin-top: 0; +} +table.tableblock { + border-width: 3px; + border-spacing: 0px; + border-style: solid; + border-color: #527bbd; + border-collapse: collapse; +} +th.tableblock, td.tableblock { + border-width: 1px; + padding: 4px; + border-style: solid; + border-color: #527bbd; +} + +table.tableblock.frame-topbot { + border-left-style: hidden; + border-right-style: hidden; +} +table.tableblock.frame-sides { + border-top-style: hidden; + border-bottom-style: hidden; +} +table.tableblock.frame-none { + border-style: hidden; +} + +th.tableblock.halign-left, td.tableblock.halign-left { + text-align: left; +} +th.tableblock.halign-center, td.tableblock.halign-center { + text-align: center; +} +th.tableblock.halign-right, td.tableblock.halign-right { + text-align: right; +} + +th.tableblock.valign-top, td.tableblock.valign-top { + vertical-align: top; +} +th.tableblock.valign-middle, td.tableblock.valign-middle { + vertical-align: middle; +} +th.tableblock.valign-bottom, td.tableblock.valign-bottom { + vertical-align: bottom; +} + + +/* + * manpage specific + * + * */ + +body.manpage h1 { + padding-top: 0.5em; + padding-bottom: 0.5em; + border-top: 2px solid silver; + border-bottom: 2px solid silver; +} +body.manpage h2 { + border-style: none; +} +body.manpage div.sectionbody { + margin-left: 3em; +} + +@media print { + body.manpage div#toc { display: none; } +} + + +</style> +<script type="text/javascript"> +/*<+'])'); + // Function that scans the DOM tree for header elements (the DOM2 + // nodeIterator API would be a better technique but not supported by all + // browsers). + var iterate = function (el) { + for (var i = el.firstChild; i != null; i = i.nextSibling) { + if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { + var mo = re.exec(i.tagName); + if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { + result[result.length] = new TocEntry(i, getText(i), mo[1]-1); + } + iterate(i); + } + } + } + iterate(el); + return result; + } + + var toc = document.getElementById("toc"); + if (!toc) { + return; + } + + // Delete existing TOC entries in case we're reloading the TOC. + var tocEntriesToRemove = []; + var i; + for (i = 0; i < toc.childNodes.length; i++) { + var entry = toc.childNodes[i]; + if (entry.nodeName.toLowerCase() == 'div' + && entry.getAttribute("class") + && entry.getAttribute("class").match(/^toclevel/)) + tocEntriesToRemove.push(entry); + } + for (i = 0; i < tocEntriesToRemove.length; i++) { + toc.removeChild(tocEntriesToRemove[i]); + } + + // Rebuild TOC entries. + var entries = tocEntries(document.getElementById("content"), toclevels); + for (var i = 0; i < entries.length; ++i) { + var entry = entries[i]; + if (entry.element.id == "") + entry.element.id = "_toc_" + i; + var a = document.createElement("a"); + a.href = "#" + entry.element.id; + a.appendChild(document.createTextNode(entry.text)); + var div = document.createElement("div"); + div.appendChild(a); + div.className = "toclevel" + entry.toclevel; + toc.appendChild(div); + } + if (entries.length == 0) + toc.parentNode.removeChild(toc); +}, + + +///////////////////////////////////////////////////////////////////// +// Footnotes generator +///////////////////////////////////////////////////////////////////// + +/* Based on footnote generation code from: + * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html + */ + +footnotes: function () { + // Delete existing footnote entries in case we're reloading the footnodes. + var i; + var noteholder = document.getElementById("footnotes"); + if (!noteholder) { + return; + } + var entriesToRemove = []; + for (i = 0; i < noteholder.childNodes.length; i++) { + var entry = noteholder.childNodes[i]; + if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") + entriesToRemove.push(entry); + } + for (i = 0; i < entriesToRemove.length; i++) { + noteholder.removeChild(entriesToRemove[i]); + } + + // Rebuild footnote entries. + var cont = document.getElementById("content"); + var spans = cont.getElementsByTagName("span"); + var refs = {}; + var n = 0; + for (i=0; i<spans.length; i++) { + if (spans[i].className == "footnote") { + n++; + var note = spans[i].getAttribute("data-note"); + if (!note) { + // Use [\s\S] in place of . so multi-line matches work. + // Because JavaScript has no s (dotall) regex flag. + note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1]; + spans[i].innerHTML = + "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n + + "' title='View footnote' class='footnote'>" + n + "</a>]"; + spans[i].setAttribute("data-note", note); + } + noteholder.innerHTML += + "<div class='footnote' id='_footnote_" + n + "'>" + + "<a href='#_footnoteref_" + n + "' title='Return to text'>" + + n + "</a>. " + note + "</div>"; + var id =spans[i].getAttribute("id"); + if (id != null) refs["#"+id] = n; + } + } + if (n == 0) + noteholder.parentNode.removeChild(noteholder); + else { + // Process footnoterefs. + for (i=0; i<spans.length; i++) { + if (spans[i].className == "footnoteref") { + var href = spans[i].getElementsByTagName("a")[0].getAttribute("href"); + href = href.match(/#.*/)[0]; // Because IE return full URL. + n = refs[href]; + spans[i].innerHTML = + "[<a href='#_footnote_" + n + + "' title='View footnote' class='footnote'>" + n + "</a>]"; + } + } + } +}, + +install: function(toclevels) { + var timerId; + + function reinstall() { + asciidoc.footnotes(); + if (toclevels) { + asciidoc.toc(toclevels); + } + } + + function reinstallAndRemoveTimer() { + clearInterval(timerId); + reinstall(); + } + + timerId = setInterval(reinstall, 500); + if (document.addEventListener) + document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); + else + window.onload = reinstallAndRemoveTimer; +} + +} +asciidoc.install(3); +/*]]>*/ +</script> +</head> +<body class="article"> +<div id="header"> +<h1>Migration Guide for the Next Scripting Language</h1> +<span id="author">Gustaf Neumann</span><br /> +<span id="email"><code><<a href="mailto:neumann@wu-wien.ac.at">neumann@wu-wien.ac.at</a>></code></span><br /> +<span id="revnumber">version 2.2.0,</span> +<span id="revdate">September 2018</span> +<br /><span id="revremark"></span> <div id="toc"> <div id="toctitle">Table of Contents</div> <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript> -</div> -</div> -<div id="content"> -<div id="preamble"> -<div class="sectionbody"> -<div class="sidebarblock"> -<div class="content"> -<div class="title">Abstract</div> -<div class="paragraph"><p>This document describes the differences between the Next Scripting -Language Framework and XOTcl 1. In particular, it presents a -migration guide from XOTcl 1 to NX, and presents potential -incompatibilities between XOTcl 1 and XOTcl 2.</p></div> -</div></div> -<div class="paragraph"><p>The Next Scripting Language (NX) is a successor of XOTcl 1 and is -based on 10 years of experience with XOTcl in projects containing -several hundert thousand lines of code. While XOTcl was the first -language designed to provide language support for design patterns, the -focus of the Next Scripting Framework and NX are on combining this -with Language Oriented Programming. In many respects, NX was designed -to ease the learning of the language by novices (by using a more -mainstream terminology, higher orthogonality of the methods, less -predefined methods), to improve maintainability (remove sources of -common errors) and to encourage developer to write better structured -programs (to provide interfaces) especially for large projects, where -many developers are involved.</p></div> -<div class="paragraph"><p>The Next Scripting Language is based on the Next Scripting Framework -which was developed based on the notion of language oriented -programming. The Next Scripting Frameworks provides C-level support -for defining and hosting multiple object systems in a single Tcl -interpreter. The whole definition of NX is fully scripted -(e.g. defined in <code>nx.tcl</code>). The Next Scripting Framework is shipped -with three language definitions, containing NX and XOTcl 2. Most of -the existing XOTcl 1 programs can be used without modification in the -Next Scripting Framework by using XOTcl 2. The Next Scripting -Framework requires Tcl 8.5 or newer.</p></div> -<div class="paragraph"><p>Although NX is fully scripted (as well as XOTcl 2), our benchmarks -show that scripts based on NX are often 2 or 4 times faster than the -counterparts in XOTcl 1. But speed was not the primary focus on the -Next Scripting Environment: The goal was primarily to find ways to -repackage the power of XOTcl in an easy to learn environment, highly -orthogonal environment, which is better suited for large projects, -trying to reduce maintenance costs.</p></div> -<div class="paragraph"><p>We expect that many user will find it attractive to upgrade -from XOTcl 1 to XOTcl 2, and some other users will upgrade to NX. -This document focuses mainly on the differences between XOTcl 1 and -NX, but addresses as well potential incompatibilities between XOTcl 1 -and XOTcl 2. For an introduction to NX, please consult the NX tutorial.</p></div> -</div> -</div> -<div class="sect1"> -<h2 id="_differences_between_xotcl_and_nx">1. Differences Between XOTcl and NX</h2> -<div class="sectionbody"> -<div class="paragraph"><p>The Next Scripting Framework supports <em>Language Oriented Programming</em> -by providing means to define potentially multiple object systems with -different naming and functionality in a single interpreter. This -makes the Next Scripting Framework a powerful instrument for defining -multiple languages such as e.g. domain specific languages. This focus -differs from XOTcl 1.</p></div> -<div class="paragraph"><p>Technically, the language framework approach means that the languages -implemented by the Next Scripting Framework (most prominently XOTcl 2 -and NX) are typically fully scripted and can be loaded via the usual -Tcl <code>package require</code> mechanism.</p></div> -<div class="paragraph"><p>Some of the new features below are provided by the Next Scripting -Framework, some are implemented via the script files for XOTcl 2 and -NX.</p></div> -<div class="sect2"> -<h3 id="_features_of_nx">1.1. Features of NX</h3> -<div class="paragraph"><p>In general, the Next Scripting Language (NX) differs from XOTcl -in the following respects:</p></div> -<div class="olist arabic"><ol class="arabic"> -<li> -<p> -<strong>Stronger Encapsulation:</strong> The Next Scripting Language favors - a <em>stronger form of encapsulation</em> than XOTcl. Calling the own - methods or accessing the own instance variables is typographically - easier and computationally faster than these operations on other - objects. This behavior is achieved via <em>resolvers</em>, which make some - methods necessary in XOTcl 1 obsolete in NX (especially for importing - instance variables). The encapsulation of NX is stronger than in - XOTcl but still weak compared to languages like C++; a developer can - still access other objects' variables via some idioms, but NX <em>makes - accesses to other objects' variables explicit</em>. The requiredness to - make these accesses explicit should encourage developer to implement - well defined interfaces to provide access to instance variables. -</p> -</li> -<li> -<p> -<strong>Additional Forms of Method Definition and Reuse:</strong> - The Next Scripting Language - provides much more orthogonal means to <em>define, reuse and - introspect</em> scripted and C-implemented methods. -</p> -<div class="olist loweralpha"><ol class="loweralpha"> -<li> -<p> -It is possible to use NX <code>alias</code> to register methods - under arbitrary names for arbitrary objects or classes. -</p> -</li> -<li> -<p> -NX provides means for <em>method protection</em> (method modifiers - <code>public</code>, <code>protected</code>, and <code>private</code>). Therefore developers have - to define explicitly public interfaces in order to use methods - from other objects. -</p> -</li> -<li> -<p> -One can invoke in NX fully qualified methods to invoke - methods outside the precedence path. -</p> -</li> -<li> -<p> -One can define in NX <em>hierarchical method names</em> (similar to - commands and subcommands, called method ensembles) in a - convenient way to provide extensible, hierarchical naming of - methods. -</p> -</li> -<li> -<p> -One can use in NX the same interface to query (introspect) - C-implemented and scripted methods/commands. -</p> -</li> -</ol></div> -</li> -<li> -<p> -<strong>Orthogonal Parameterization:</strong> - The Next Scripting Language provides an <em>orthogonal framework for - parametrization</em> of methods and objects. -</p> -<div class="olist loweralpha"><ol class="loweralpha"> -<li> -<p> -In NX, the same argument parser is used for -</p> -<div class="ulist"><ul> -<li> -<p> -Scripted Methods -</p> -</li> -<li> -<p> -C-implemented methods and Tcl commands -</p> -</li> -<li> -<p> -Object Parametrization -</p> -</li> -</ul></div> -</li> -<li> -<p> -While XOTcl 1 provided only value-checkers for non-positional - arguments for methods, the Next Scripting Framework provides - the same value checkers for positional and non-positional - arguments of methods, as well as for positional and - non-positional configure parameters (<code>-parameter</code> in - XOTcl 1). -</p> -</li> -<li> -<p> -While XOTcl 1 supported only non-positional arguments at the - begin of the argument list, these can be used now at arbitrary - positions. -</p> -</li> -</ol></div> -</li> -<li> -<p> -<strong>Value Checking:</strong> -</p> -<div class="olist loweralpha"><ol class="loweralpha"> -<li> -<p> -The Next Scripting Language supports checking of the <em>input - parameters</em> and the <em>return values</em> of scripted and C-implemented - methods and commands. -</p> -</li> -<li> -<p> -NX provides a set of predefined checkers (like e.g. <code>integer</code>, - <code>boolean</code>, <code>object</code>, …) which can be extended by the - applications. -</p> -</li> -<li> -<p> -Value Checking can be used for <em>single</em> and <em>multi-valued</em> - parameters. One can e.g. define a list of integers - with at least one entry by the parameter specification - <code>integer,1..n</code>. -</p> -</li> -<li> -<p> -Value Checking can be turned on/off globally or on the - method/command level. -</p> -</li> -</ol></div> -</li> -<li> -<p> -<strong>Scripted Init Blocks:</strong> The Next Scripting Language provides - <em>scripted init blocks</em> for objects and classes (replacement for the - dangerous dash "-" mechanism in XOTcl that allows one to set variables - and invoke methods upon object creation). -</p> -</li> -<li> -<p> -<strong>More Conventional Naming for Predefined Methods:</strong> The naming of - the methods in the Next Scripting Language is much more in line with - the mainstream naming conventions in OO languages. While for example - XOTcl uses <code>proc</code> and <code>instproc</code> for object specific and inheritable - methods, NX uses simply <code>method</code>. -</p> -</li> -<li> -<p> -<strong>Profiling Support:</strong> The Next Scripting Language provides now two - forms of profiling -</p> -<div class="ulist"><ul> -<li> -<p> -Profiling via a DTrace provider (examples are e.g. in the dtrace - subdirectory of the source tree) -</p> -</li> -<li> -<p> -Significantly improved built-in profiling (results can be - processed in Tcl). -</p> -</li> -</ul></div> -</li> -<li> -<p> -<strong>Significantly Improved Test Suite:</strong> The regression test suite of - Next Scripting Scripting framework contain now more than - 5.000 tests, and order of magnitude more than in XOTcl 1.6 -</p> -</li> -<li> -<p> -<strong>Much Smaller Interface:</strong> The Next Scripting Language has a much - <em>smaller interface</em> (i.e. provides less predefined methods) than - XOTcl (see Table 1), although the expressiveness was increased in - NX. -</p> -</li> -</ol></div> -<div class="tableblock"> -<table rules="all" -width="50%" -frame="hsides" -cellspacing="0" cellpadding="4"> -<caption class="title">Table 1. Comparison of the Number of Predefined Methods in NX and XOTcl</caption> -<col width="60%" /> -<col width="20%" /> -<col width="20%" /> -<thead> -<tr> -<th align="left" valign="top"></th> -<th align="right" valign="top">NX</th> -<th align="right" valign="top">XOTcl</th> -</tr> -</thead> -<tfoot> -<tr> -<td align="left" valign="top"><p class="table">Total</p></td> -<td align="right" valign="top"><p class="table">45</p></td> -<td align="right" valign="top"><p class="table">124</p></td> -</tr> -</tfoot> -<tbody> -<tr> -<td align="left" valign="top"><p class="table">Methods for Objects</p></td> -<td align="right" valign="top"><p class="table">14</p></td> -<td align="right" valign="top"><p class="table">51</p></td> -</tr> -<tr> -<td align="left" valign="top"><p class="table">Methods for Classes</p></td> -<td align="right" valign="top"><p class="table">9</p></td> -<td align="right" valign="top"><p class="table">24</p></td> -</tr> -<tr> -<td align="left" valign="top"><p class="table">Info-methods for Objects</p></td> -<td align="right" valign="top"><p class="table">11</p></td> -<td align="right" valign="top"><p class="table">25</p></td> -</tr> -<tr> -<td align="left" valign="top"><p class="table">Info-methods for Classes</p></td> -<td align="right" valign="top"><p class="table">11</p></td> -<td align="right" valign="top"><p class="table">24</p></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>This comparison list compares mostly XOTcl 1 with NX, some features -are also available in XOTcl 2 (2a, 2c 2d, 3, 4).</p></div> -</div> -<div class="sect2"> -<h3 id="_nx_and_xotcl_scripts">1.2. NX and XOTcl Scripts</h3> -<div class="paragraph"><p>Below is a small, introductory example showing an implementation of a -class <code>Stack</code> in NX and XOTcl. The purpose of this first example is -just a quick overview. We will go into much more detailed comparison -in the next sections.</p></div> -<div class="paragraph"><p>NX supports a block syntax, where the methods are defined during the -creation of the class. The XOTcl syntax is slightly more redundant, -since every definition of a method is a single toplevel command -starting with the class name (also NX supports the style used in -XOTcl). In NX, all methods are per default protected (XOTcl does not -support protection). In NX methods are defined in the definition of -the class via <code>:method</code> or <code>:public method</code>. In XOTcl methods are -defined via the <code>instproc</code> method.</p></div> -<div class="paragraph"><p>Another difference is the notation to refer to instance variables. In -NX, instance variable are named with a single colon in the front. In -XOTcl, instance variables are imported using <code>instvar</code>.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="top">Stack example in NX </th> -<th align="left" valign="top">Stack example in XOTcl</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="top"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Stack { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Stack of Things -</span> <span class='nx-comment'># -</span> - <span class='nx-keyword'>:variable</span> things <span class='nx-string'>""</span> - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing} { - <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0 <span class='nx-variable'>$thing</span>] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> - } - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> pop {} { - <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0] - <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 1 end] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$top</span> - } -}</pre></div></div></div></td> -<td align="left" valign="top"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># Stack of Things -</span><span class='nx-comment'># -</span> -<span class='nx-keyword'>Class</span> Stack - -Stack instproc <span class='nx-keyword'>init</span> {} { - <span class='nx-keyword'>my</span> instvar things - <span class='nx-keyword'>set</span> things <span class='nx-string'>""</span> -} - -Stack instproc push {thing} { - <span class='nx-keyword'>my</span> instvar things - <span class='nx-keyword'>set</span> things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>$things</span> 0 <span class='nx-variable'>$thing</span>] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> -} - -Stack instproc pop {} { - <span class='nx-keyword'>my</span> instvar things - <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>$things</span> 0] - <span class='nx-keyword'>set</span> things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>$things</span> 1 end] -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect2"> -<h3 id="_using_xotcl_2_0_and_the_next_scripting_language_in_a_single_interpreter">1.3. Using XOTcl 2.0 and the Next Scripting Language in a Single Interpreter</h3> -<div class="paragraph"><p>In general, the Next Scripting Framework supports multiple object -systems concurrently. Effectively, every object system has different -base classes for creating objects and classes. Therefore, these object -systems can have different interfaces and names of built-in -methods. Currently, the Next Scripting Framework is packaged with -three object systems:</p></div> -<div class="ulist"><ul> -<li> -<p> -NX -</p> -</li> -<li> -<p> -XOTcl 2.0 -</p> -</li> -<li> -<p> -TclCool -</p> -</li> -</ul></div> -<div class="paragraph"><p>XOTcl 2 is highly compatible with XOTcl 1, the language NX is -described below in more details, the language TclCool was introduced -in Tip#279 and serves primarily an example of a small OO language.</p></div> -<div class="paragraph"><p>A single Tcl interpreter can host multiple Next Scripting Object -Systems at the same time. This fact makes migration from XOTcl to NX -easier. The following example script shows to use XOTcl and NX in a -single script:</p></div> -<div class="listingblock"> -<div class="title">Using Multiple Object Systems in a single Script</div> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>namespace</span> <span class='nx-keyword'>eval</span> mypackage { - - <span class='nx-keyword'>package</span> <span class='nx-keyword'>require</span> XOTcl 2.0 - - <span class='nx-comment'># Define a class with a public method foo using XOTcl -</span> <span class='nx-keyword'>xotcl::Class</span> C1 - C1 instproc foo {} {<span class='nx-keyword'>puts</span> <span class='nx-string'>"hello world"</span>} - - <span class='nx-keyword'>package</span> <span class='nx-keyword'>require</span> nx - - <span class='nx-comment'># Define a class with a public method foo using NX -</span> <span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C2 { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>puts</span> <span class='nx-string'>"hello world"</span>} - } -}</pre></div></div> -<div class="paragraph"><p>One could certainly create object or classes from the different object -systems via fully qualified names (e.g. using e.g. <code>::xotcl::Class</code> or -<code>::nx::Class</code>), but for migration for systems without explicit -namespaces switching between the object systems eases migration. -"Switching" between XOTcl and NX effectively means the load some -packages (if needed) and to import either the base classes (Object and -Class) of XOTcl or NX into the current namespace.</p></div> -</div> -</div> -</div> -<div class="sect1"> -<h2 id="_xotcl_idioms_in_the_next_scripting_language">2. XOTcl Idioms in the Next Scripting Language</h2> -<div class="sectionbody"> -<div class="paragraph"><p>The following sections are intended for reader familiar with XOTcl and -show, how certain language Idioms of XOTcl can be expressed in NX. In -some cases, multiple possible realizations are listed</p></div> -<div class="sect2"> -<h3 id="_defining_objects_and_classes">2.1. Defining Objects and Classes</h3> -<div class="paragraph"><p>When creating objects or classes, one should use the method <code>create</code> -explicitly. In XOTcl, a default <code>unknown</code> method handler was provided for -classes, which create for every unknown method invocation an -object/class with the name of the invoked method. This technique was -convenient, but as well dangerous, since typos in method names lead -easily to unexpected behavior. This default unknown method handler is not -provided in NX (but can certainly be provided as a one-liner in NX by -the application).</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> ClassName</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> ClassName</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Object</span> ObjectName</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> ObjectName</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect2"> -<h3 id="_defining_methods">2.2. Defining Methods</h3> -<div class="paragraph"><p>In general, both XOTcl and NX support methods on the object level -(per-object methods, i.e. methods only applicable to a single object) -and on the class level (methods inherited to instances of the -classes). While the naming in XOTcl tried to follow closely the Tcl -tradition (using the term <code>proc</code> for functions/methods), NX uses the -term <code>method</code> for defining scripted methods.</p></div> -<div class="paragraph"><p>XOTcl uses the prefix <code>inst</code> to denote that methods are provided for -instances, calling therefore scripted methods for instances -<code>instproc</code>. This is certainly an unusual term. The approach with the -name prefix has the disadvantage, that for every different kind of -method, two names have to be provided (e.g. <code>proc</code> and <code>instproc</code>, -<code>forward</code> and <code>instforward</code>).</p></div> -<div class="paragraph"><p>NX on the contrary uses the same term for defining instance method or -object-specific methods. When the term (e.g. <code>method</code>) is used on a -class, the method will be an instance method (i.e. applicable to the -instances of the class). When the term is used on an object with the -modifier <code>object</code>, an object-specific method is defined. This way one -can define the same way object specific methods on an object as well -as on a class.</p></div> -<div class="paragraph"><p>Furthermore, both XOTcl and NX distinguish between scripted methods -(section 3.2.1) and C-defined methods (section 3.2.2). Section 3.2.3 -introduces method protection, which is only supported by NX.</p></div> -<div class="sect3"> -<h4 id="_scripted_methods_defined_in_the_init_block_of_a_class_object_or_with_separate_calls">2.2.1. Scripted Methods Defined in the Init-block of a Class/Object or with Separate Calls</h4> -<div class="paragraph"><p>The following examples show the definition of a class and its methods -in the init-block of a class (NX only), and the definition of methods -via separate top level calls (XOTcl and NX).</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define instance method 'foo' and object -</span><span class='nx-comment'># method 'bar' for a Class 'C' with separate -</span><span class='nx-comment'># toplevel commands -</span> -<span class='nx-keyword'>Class</span> C -C instproc foo args {...} -C <span class='nx-keyword'>proc</span> bar args {...}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define instance method and object method -</span><span class='nx-comment'># in the init-block of a class -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:method</span> foo args {...} - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>method</span> bar args {...} -}</pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define instance method and object method -</span><span class='nx-comment'># with separate commands -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C -C <span class='nx-keyword'>method</span> foo args {...} -C <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar args {...}</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define object-specific method foo -</span><span class='nx-comment'># for an object 'o' with separate commands -</span> -<span class='nx-keyword'>Object</span> o -o <span class='nx-keyword'>set</span> x 1 -o <span class='nx-keyword'>proc</span> foo args {...}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define object method and set -</span><span class='nx-comment'># instance variable in the init-block of -</span><span class='nx-comment'># an object -</span> -<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { - <span class='nx-keyword'>set</span> :x 1 - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>method</span> foo args {...} -}</pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define object method and set -</span><span class='nx-comment'># instance variable with separate -</span><span class='nx-comment'># commands -</span> -<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o -o <span class='nx-keyword'>eval</span> {<span class='nx-keyword'>set</span> :x 1} -o <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo args {...}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_different_kinds_of_methods">2.2.2. Different Kinds of Methods</h4> -<div class="paragraph"><p>This section describes various kinds of methods. The different kinds -of methods are defined via different method-defining methods, which -are summarized in the following table for XOTcl and NX.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Methods for defining methods: -</span><span class='nx-comment'># -</span><span class='nx-comment'># proc -</span><span class='nx-comment'># instproc -</span><span class='nx-comment'># forward -</span><span class='nx-comment'># instforward -</span><span class='nx-comment'># parametercmd -</span><span class='nx-comment'># instparametercmd -</span><span class='nx-comment'># -</span><span class='nx-comment'># All these methods return empty.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Methods for defining methods: -</span><span class='nx-comment'># -</span><span class='nx-comment'># alias -</span><span class='nx-comment'># forward -</span><span class='nx-comment'># method -</span><span class='nx-comment'># -</span><span class='nx-comment'># All these methods return method-handles.</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>In addition to scripted methods (previous section) XOTcl supports -forwarder (called <code>forward</code> and <code>instforward</code>) and accessor functions -to variables (called <code>parametercmd</code> and <code>instparametercmd</code>). The -accessor functions are used normally internally when object-specific -parameters are defined (see Section 3.4).</p></div> -<div class="paragraph"><p>In NX forwarders are called <code>forward</code>. NX does not provide a public -available method to define variable accessors like <code>parametercmd</code> in -XOTcl, but use internally the Next Scripting Framework primitive -<code>nsf::method::setter</code> when appropriate.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> C -C instforward f1 ... -C <span class='nx-keyword'>forward</span> f2 ... - -<span class='nx-keyword'>Object</span> o -o <span class='nx-keyword'>forward</span> f3 ...</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define forwarder -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:forward</span> f1 ... - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>forward</span> f2 ... -} - -<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>forward</span> f3 ... -}</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define setter and getter methods in XOTcl. -</span><span class='nx-comment'># -</span><span class='nx-comment'># XOTcl provides methods for these. -</span> -<span class='nx-keyword'>Class</span> C -C instparametercmd p1 -C parametercmd p2 - -<span class='nx-keyword'>Object</span> o -o parametercmd p3</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define setter and getter methods in NX. -</span><span class='nx-comment'># -</span><span class='nx-comment'># NX does not provide own methods, but uses -</span><span class='nx-comment'># the low level framework commands, since -</span><span class='nx-comment'># application developer will only -</span><span class='nx-comment'># need it in rare cases. -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C -::nsf::method::setter C p1 -::nsf::method::setter C -per-object p2 - -<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o -::nsf::method::setter o p3</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>NX supports in contrary to XOTcl the method <code>alias</code> which can be used -to register arbitrary Tcl commands or methods for an object or class -under a provided method name. Aliases can be used to reuse a certain implementation in -e.g. different object systems under potentially different names. In -some respects aliases are similar to forwarders, but they do not -involve forwarding overhead.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Method "alias" not available</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define method aliases -</span><span class='nx-comment'># (to scripted or non-scripted methods) -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:alias</span> a1 ... - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>alias</span> a2 ... -} - -<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>alias</span> a3 ... -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="method-protect-example">2.2.3. Method Modifiers and Method Protection</h4> -<div class="paragraph"><p>NX supports four method modifiers <code>object</code>, <code>public</code>, <code>protected</code> and -<code>private</code>. All method modifiers can be written in front of every -method defining command. The method modifier <code>object</code> is used to denote -object-specific methods (see above). The concept of method protection -is new in NX.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Method modifiers -</span><span class='nx-comment'># -</span><span class='nx-comment'># "object", -</span><span class='nx-comment'># "public", -</span><span class='nx-comment'># "protected", and -</span><span class='nx-comment'># "private" -</span><span class='nx-comment'># -</span><span class='nx-comment'># are not available</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Method modifiers -</span><span class='nx-comment'># -</span><span class='nx-comment'># "object", -</span><span class='nx-comment'># "public", -</span><span class='nx-comment'># "protected" -</span><span class='nx-comment'># -</span><span class='nx-comment'># are applicable for all kinds of -</span><span class='nx-comment'># method defining methods: -</span><span class='nx-comment'># -</span><span class='nx-comment'># method, forward, alias -</span><span class='nx-comment'># -</span><span class='nx-comment'># The modifier "private" is available for -</span><span class='nx-comment'># -</span><span class='nx-comment'># method, forward, alias -</span><span class='nx-comment'># -</span><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - :/<span class='nx-keyword'>method</span>-definition-method/ ... - <span class='nx-keyword'>:public</span> /<span class='nx-keyword'>method</span>-definition-method/ ... - <span class='nx-keyword'>:protected</span> /<span class='nx-keyword'>method</span>-definition-method/ ... - <span class='nx-keyword'>:private</span> /<span class='nx-keyword'>method</span>-definition-method/ ... - <span class='nx-keyword'>:object</span> /<span class='nx-keyword'>method</span>-definition-method/ ... - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> /<span class='nx-keyword'>method</span>-definition-method/ ... - <span class='nx-keyword'>:protected</span> <span class='nx-keyword'>object</span> /<span class='nx-keyword'>method</span>-definition-method/ ... - <span class='nx-keyword'>:private</span> <span class='nx-keyword'>object</span> /<span class='nx-keyword'>method</span>-definition-method/ ... -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>XOTcl does not provide method protection. In NX, all methods are -defined per default as protected. This default can be changed by the -application developer in various ways. The command <code>::nx::configure -defaultMethodCallProtection true|false</code> can be used to set the default -call protection for scripted methods, forwarder and aliases. -The defaults can be overwritten also on a class level.</p></div> -<div class="paragraph"><p>NX provides means for method hiding via the method modifier -<code>private</code>. Hidden methods can be invoked only via the <code>-local</code> flag, -which means: "call the specified method defined in the same -class/object as the currently executing method".</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># XOTcl provides no means for -</span><span class='nx-comment'># method hiding</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Hiding of methods via "private" -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Base { - <span class='nx-keyword'>:private</span> <span class='nx-keyword'>method</span> baz {a b} {<span class='nx-keyword'>expr</span> {<span class='nx-variable'>$a</span> + <span class='nx-variable'>$b</span>}} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {a b} {: -local baz <span class='nx-variable'>$a</span> <span class='nx-variable'>$b</span>} -} - -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Sub -superclass Base { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bar {a b} {: -local baz <span class='nx-variable'>$a</span> <span class='nx-variable'>$b</span>} - <span class='nx-keyword'>:private</span> <span class='nx-keyword'>method</span> baz {a b} {<span class='nx-keyword'>expr</span> {<span class='nx-variable'>$a</span> * <span class='nx-variable'>$b</span>}} - - <span class='nx-keyword'>:create</span> s1 -} - -s1 foo 3 4 ;<span class='nx-comment'># returns 7 -</span>s1 bar 3 4 ;<span class='nx-comment'># returns 12 -</span>s1 baz 3 4 ;<span class='nx-comment'># unable to dispatch method 'baz'</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="method-deletion">2.2.4. Method Deletion</h4> -<div class="paragraph"><p>NX provides an explicit <code>delete</code> method for the deletion of methods.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># XOTcl provides only method deletion with -</span><span class='nx-comment'># the equivalent of Tcl's "proc foo {} {}" -</span><span class='nx-placeholder'>/cls/</span> instproc foo {} {} -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>proc</span> foo {} {}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Deletion of Methods -</span><span class='nx-comment'># -</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>method</span> <span class='nx-placeholder'>/name/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_resolvers">2.3. Resolvers</h3> -<div class="paragraph"><p>The Next Scripting Framework defines Tcl resolvers for method and -variable names to implement object specific behavior. Within the -bodies of scripted methods these resolver treat variable and function -names starting with a colon <code>:</code> specially. In short, a colon-prefixed -variable name refers to an instance variable, and a colon-prefixed -function name refers to a method. The sub-sections below provide -detailed examples.</p></div> -<div class="paragraph"><p>Note that the resolvers of the Next Scripting Framework can be used in -the XOTcl 2.* environment as well.</p></div> -<div class="sect3"> -<h4 id="_invoking_methods">2.3.1. Invoking Methods</h4> -<div class="paragraph"><p>In XOTcl, a method of the same object can be invoked via <code>my</code>, or in -general via using the name of the object in front of the method name.</p></div> -<div class="paragraph"><p>In NX, the own methods are called via the method name prefixed with a -single colon. The invocation of the methods of other objects is the -same in NX and XOTcl.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> C -C instproc foo args {...} -C instproc bar args { - <span class='nx-keyword'>my</span> foo 1 2 3 ;<span class='nx-comment'># invoke own method -</span> o baz ;<span class='nx-comment'># invoke other object's method -</span>} -<span class='nx-keyword'>Object</span> o -o <span class='nx-keyword'>proc</span> baz {} {...}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:method</span> foo args {...} - <span class='nx-keyword'>:method</span> bar args { - :foo 1 2 3 ;<span class='nx-comment'># invoke own method -</span> o baz ;<span class='nx-comment'># invoke other object's method -</span> } -} -<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> baz {} {...} -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_accessing_own_instance_variables_from_method_bodies">2.3.2. Accessing Own Instance Variables from Method Bodies</h4> -<div class="paragraph"><p>In general, the Next Scripting Language favors the access to an -objects’s own instance variables over variable accesses of other -objects. This means that in NX it is syntactically easier to access -the own instance variables. On the contrary, in XOTcl, the variable -access to own and other variables are fully symmetric.</p></div> -<div class="paragraph"><p>In XOTcl, the following approaches are used to access instance -variables:</p></div> -<div class="ulist"><ul> -<li> -<p> -Import instance variables via <code>instvar</code> and access variables via <code>$varName</code> -</p> -</li> -<li> -<p> -Set or get instance variables via <code>my set varName ?value?</code> or other - variable accessing methods registered on <code>xotcl::Object</code> such as - <code>append</code>, <code>lappend</code>, <code>incr</code>, etc. -</p> -</li> -<li> -<p> -Register same-named accessor functions and set/get values - of instance variables via <code>my varName ?value?</code> -</p> -</li> -</ul></div> -<div class="paragraph"><p>In NX, the favored approach to access instance variables is to use -the name resolvers, although it is as well possible to import -variables via <code>nx::var import</code> or to check for the existence of -instance variables via <code>nx::var exists</code>.</p></div> -<div class="paragraph"><p>The following examples summary the use cases for accessing the own and -other instance variables.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> C -C instproc foo args { - <span class='nx-comment'># Method scoped variable a -</span> <span class='nx-keyword'>set</span> a 1 - <span class='nx-comment'># Instance variable b -</span> <span class='nx-keyword'>my</span> instvar b - <span class='nx-keyword'>set</span> b 2 - <span class='nx-comment'># Global variable/namespaced variable c -</span> <span class='nx-keyword'>set</span> ::c 3 -}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:method</span> foo args {...} - <span class='nx-comment'># Method scoped variable a -</span> <span class='nx-keyword'>set</span> a 1 - <span class='nx-comment'># Instance variable b -</span> <span class='nx-keyword'>set</span> :b 2 - <span class='nx-comment'># Global variable/namespaced variable c -</span> <span class='nx-keyword'>set</span> ::c 3 - } -}</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>... instproc ... { - <span class='nx-keyword'>my</span> <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> -}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Set own instance variable to a value via -</span><span class='nx-comment'># resolver (preferred and fastest way) -</span> -... <span class='nx-keyword'>method</span> ... { - <span class='nx-keyword'>set</span> :<span class='nx-placeholder'>/newVar/</span> <span class='nx-placeholder'>?value?</span> -}</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>... instproc ... { - <span class='nx-keyword'>my</span> instvar <span class='nx-placeholder'>/varName/</span> - <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> -}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Set own instance variable via -</span><span class='nx-comment'># variable import -</span> -... <span class='nx-keyword'>method</span> ... { - ::nx::var import [<span class='nx-keyword'>self</span>] <span class='nx-placeholder'>/varName/</span> - <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> -}</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>... instproc ... { - <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> [<span class='nx-keyword'>my</span> <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/otherVar/</span>] -}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Read own instance variable -</span> -... <span class='nx-keyword'>method</span> ... { - <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> [<span class='nx-keyword'>set</span> :<span class='nx-placeholder'>/otherVar/</span>] -}</pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>... <span class='nx-keyword'>method</span> ... { - <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/newVar/</span> <span class='nx-variable'>${</span><span class='nx-variable'>:/otherVar/}</span> -}</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>... instproc ... { - <span class='nx-keyword'>my</span> exists <span class='nx-placeholder'>/varName/</span> -}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Test existence of own instance variable -</span> -... <span class='nx-keyword'>method</span> ... { - <span class='nx-keyword'>info</span> :<span class='nx-placeholder'>/varName/</span> -}</pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'> ... <span class='nx-keyword'>method</span> ... { - ::nx::var exists [<span class='nx-keyword'>self</span>] <span class='nx-placeholder'>/varName/</span> -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_accessing_instance_variables_of_other_objects">2.3.3. Accessing Instance Variables of other Objects</h4> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Set instance variable of object obj to a -</span><span class='nx-comment'># value via resolver -</span><span class='nx-comment'># (preferred way: define property on obj) -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>eval</span> [<span class='nx-keyword'>list</span> <span class='nx-keyword'>set</span> :<span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span>]</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> [<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/otherVar/</span>]</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Read instance variable of object obj -</span><span class='nx-comment'># via resolver -</span> -<span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> [<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>eval</span> {<span class='nx-keyword'>set</span> :<span class='nx-placeholder'>/otherVar/</span>}]</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>... instproc ... { - <span class='nx-placeholder'>/obj/</span> instvar <span class='nx-placeholder'>/varName/</span> - <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> -}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Read instance variable of object /obj/ -</span><span class='nx-comment'># via import -</span> -... <span class='nx-keyword'>method</span> ... { - ::nx::var import <span class='nx-placeholder'>/obj/</span> <span class='nx-placeholder'>/varName/</span> - <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> -}</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> exists varName</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Test existence of instance variable of -</span><span class='nx-comment'># object obj -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>eval</span> {<span class='nx-keyword'>info</span> exists :<span class='nx-placeholder'>/varName/</span>}</pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nx::var exists <span class='nx-placeholder'>/obj/</span> <span class='nx-placeholder'>/varName/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_parameters">2.4. Parameters</h3> -<div class="paragraph"><p>While XOTcl 1 had very limited forms of parameters, XOTcl 2 and NX -provide a generalized and highly orthogonal parameter machinery -handling various kinds of value constraints (also called value -checkers). Parameters are used to specify,</p></div> -<div class="ulist"><ul> -<li> -<p> -how objects and classes are initialized (we call these parameter types - <em>Configure Parameters</em>), and -</p> -</li> -<li> -<p> -what values can be passed to methods (we call these <em>Method - Parameters</em>). -</p> -</li> -</ul></div> -<div class="paragraph"><p>Furthermore, parameters might be positional or non-positional, they -might be optional or required, they might have a defined multiplicity, -and value-types, they might be introspected, etc. The Next Scripting -Framework provide a unified, C-implemented infrastructure to handle -both, object and method parameters in the same way with a high degree -of orthogonality.</p></div> -<div class="paragraph"><p>Configuration parameters were specified in XOTcl 1 primarily via the -method <code>parameter</code> in a rather limited way, XOTcl 1 only supported -non-positional parameters in front of positional ones, supported no -value constraints for positional parameters, provided no distinction -between optional and required, and did not support multiplicity.</p></div> -<div class="paragraph"><p>Furthermore, the Next Scripting Framework provides optionally <em>Return -Value Checking</em> based on the same mechanism to check whether some -methods return always the values as specified.</p></div> -<div class="sect3"> -<h4 id="_parameters_for_configuring_objects_variables_and_properties">2.4.1. Parameters for Configuring Objects: Variables and Properties</h4> -<div class="paragraph"><p>Configure parameters are used for specifying values for configuring -objects when they are created (i.e. how instance variables are -initialized, what parameters can be passed in for initialization, what -default values are used, etc.). Such configuration parameters are -supported in XOTcl primarily via the method <code>parameter</code>, which is used -in XOTcl to define multiple parameters via a list of parameter -specifications.</p></div> -<div class="paragraph"><p>Since the term "parameter" is underspecified, NX uses a more -differentiated terminology. NX distinguishes between configurable -instance variables (also called <em>properties</em>) and non configurable -instance variables (called <em>variables</em>), which might have as well -e.g. default values. The values of configurable properties can be -queried at runtime via <code>cget</code>, and their values can be altered via -<code>configure</code>. When the value of a configure parameter is provided or -changed, the value checkers from the variable definition are used to -ensure, the value is permissible (i.e. it is for example an integer -value). The sum of all configurable object parameters are called -<em>configure parameters</em>. To define a define a configurable variable, NX -uses the method <code>property</code>, for non-configurable variables, the method -<code>variable</code> is used.</p></div> -<div class="paragraph"><p>Optionally, one can define in NX, that a <code>property</code> or a -<code>variable</code> should have a public, protected or private accessor. Such -an accessor is a method with the same name as the variable. In XOTcl, -every <code>parameter</code> defined as well automatically a same-named accessor -method, leading to potential name conflicts with other method names.</p></div> -<div class="paragraph"><p>In the examples below we show the definition of configurable a non-configurable instance variables using <code>variable</code> and <code>property</code> -respectively.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define class "Foo" with instance -</span><span class='nx-comment'># variables "x" and "y" initialized -</span><span class='nx-comment'># on instance creation. The initialization -</span><span class='nx-comment'># has to be performed in the constructor. -</span> -<span class='nx-keyword'>Class</span> Foo -Foo instproc <span class='nx-keyword'>init</span> args { - instvar x y - <span class='nx-keyword'>set</span> x 1 - <span class='nx-keyword'>set</span> y 2 -} - -<span class='nx-comment'># Create instance of the class Foo -</span>Foo f1 - -<span class='nx-comment'># Object f1 has instance variables -</span><span class='nx-comment'># x == 1 and y == 2</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define class "Foo" with instance variables -</span><span class='nx-comment'># "x" and "y" initialized on instance creation. -</span><span class='nx-comment'># The method "variable" is similar in syntax -</span><span class='nx-comment'># to Tcl's "variable" command. During -</span><span class='nx-comment'># instance creation, the variable -</span><span class='nx-comment'># definitions are used for the -</span><span class='nx-comment'># initialization of the variables of the object. -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - <span class='nx-keyword'>:variable</span> x 1 - <span class='nx-keyword'>:variable</span> y 2 -} - -<span class='nx-comment'># Create instance of the class Foo -</span>Foo <span class='nx-keyword'>create</span> f1 - -<span class='nx-comment'># Object f1 has instance variables -</span><span class='nx-comment'># x == 1 and y == 2</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>While XOTcl follows a procedural way to initialize variables via the -constructor <code>init</code>, NX follows a more declarative approach. Often, -classes have superclasses, which often want to provide their own -instance variables and default values. The declarative approach from -NX solves this via inheritance, while a procedural approach via -assign statements in the constructor requires explicit constructor -calls, which are often error-prone. Certainly, when a user prefers to -assign initial values to instance variables via explicit assign -operations in constructors, this is as well possible in NX.</p></div> -<div class="paragraph"><p>NX uses the same mechanism to define class variables or object -variables.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># No syntactic support for creating -</span><span class='nx-comment'># class variables</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'> -<span class='nx-comment'># Define a object variable "V" with value 100 and -</span><span class='nx-comment'># an instance variable "x". "V" is defined for the -</span><span class='nx-comment'># class object Foo, "x" is defined in the -</span><span class='nx-comment'># instances of the class. "object variable" works -</span><span class='nx-comment'># similar to "object method". -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>variable</span> V 100 - <span class='nx-keyword'>:variable</span> x 1 -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>In the next step, we define configurable instance variables which we -call <em>properties</em> in NX.</p></div> -<div class="paragraph"><p>XOTcl uses the method <code>parameter</code> is a shortcut for creating multiple -configurable variables with automatically created accessors (methods for -reading and writing of the variables). In NX, the preferred way to -create configurable variables is to use the method <code>property</code>. The -method <code>property</code> in NX is similar to <code>variable</code>, but makes the -variables configurable, which means that</p></div> -<div class="olist arabic"><ol class="arabic"> -<li> -<p> -one can specify the property as a non-positional parameter upon - creation of the object, -</p> -</li> -<li> -<p> -one can query the value via the method <code>cget</code>, and -</p> -</li> -<li> -<p> -one can modify the value of the underlying variable via the method - <code>configure</code>. -</p> -</li> -</ol></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Parameters specified as a list -</span><span class='nx-comment'># (short form); parameter -</span><span class='nx-comment'># "a" has no default, "b" has default "1" -</span> -<span class='nx-keyword'>Class</span> Foo -parameter {a {b 1} {c <span class='nx-string'>"[info tclversion]"</span>}} - -<span class='nx-comment'># Create instance of the class Foo -</span>Foo f1 -a 0 - -<span class='nx-comment'># Object f1 has instance variables -</span><span class='nx-comment'># a == 0 and b == 1 -</span> -<span class='nx-comment'># XOTcl registers automatically accessors -</span><span class='nx-comment'># for the parameters. Use the accessor -</span><span class='nx-comment'># "b" to output the value of variable "b" -</span><span class='nx-keyword'>puts</span> [f1 b] - -<span class='nx-comment'># Use the setter to alter value of -</span><span class='nx-comment'># instance variable "b" -</span>f1 b 100 - -<span class='nx-comment'># Return the substituted value of -</span><span class='nx-comment'># parameter "c", something like 8.7. -</span><span class='nx-comment'># XOTcl substitutes always when it sees -</span><span class='nx-comment'># square brackets or dollar signs. -</span>f1 c -</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define property "a" and "b". The -</span><span class='nx-comment'># property "a" has no default, "b" has -</span><span class='nx-comment'># default value "1" -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - <span class='nx-keyword'>:property</span> a - <span class='nx-keyword'>:property</span> {b 1} - <span class='nx-keyword'>:property</span> {c <span class='nx-string'>"[info tclversion]"</span>} - <span class='nx-keyword'>:property</span> {d:substdefault <span class='nx-string'>"[info tclversion]"</span>} -} - -<span class='nx-comment'># Create instance of the class Foo -</span>Foo <span class='nx-keyword'>create</span> f1 -a 0 - -<span class='nx-comment'># Object f1 has instance variables -</span><span class='nx-comment'># a == 0 and b == 1 -</span> -<span class='nx-comment'># Use the method "cget" to query the value -</span><span class='nx-comment'># of a configuration parameter -</span><span class='nx-keyword'>puts</span> [f1 <span class='nx-keyword'>cget</span> -b] - -<span class='nx-comment'># Use the method "configure" to alter the -</span><span class='nx-comment'># value of instance variable "b" -</span>f1 <span class='nx-keyword'>configure</span> -b 100 - -<span class='nx-comment'># Return the (non substituted) value of -</span><span class='nx-comment'># parameter "c", and the substituted value -</span><span class='nx-comment'># of parameter "d" -</span>f1 <span class='nx-keyword'>cget</span> -c -f1 <span class='nx-keyword'>cget</span> -d -</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>In general, NX allows one to create variables and properties with and -without accessor methods. The created accessor methods might be -<code>public</code>, <code>protected</code> or <code>public</code>. When the value <code>none</code> is provided -to <code>-accessor</code>, no accessor will be created. This is actually the -default in NX. In order to change the default behavior in NX, one can use -<code>::nx::configure defaultAccessor none|public|protected|private</code>.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># "parameter" creates always accessor -</span><span class='nx-comment'># methods, accessor methods are -</span><span class='nx-comment'># always public, no "cget" is available. -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo -parameter {a {b 1}} - -<span class='nx-comment'># Use the accessor method to query -</span><span class='nx-comment'># the value of a configuration parameter -</span><span class='nx-keyword'>puts</span> [f1 b] - -<span class='nx-comment'># Use the accessor method to set the -</span><span class='nx-comment'># value of instance variable "a" -</span>f1 a 100 - -<span class='nx-comment'># Use the accessor method to unset the -</span><span class='nx-comment'># value of instance variable "a" n.a. via -</span><span class='nx-comment'># accessor</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define property "a" and "b". The -</span><span class='nx-comment'># property "a" has no default, "b" has -</span><span class='nx-comment'># default value "1" -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - <span class='nx-keyword'>:variable</span> -accessor <span class='nx-keyword'>public</span> a - <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>public</span> {b 1} -} - -<span class='nx-comment'># Use the accessor method to query -</span><span class='nx-comment'># the value of a configuration parameter -</span><span class='nx-keyword'>puts</span> [f1 b get] - -<span class='nx-comment'># Use the accessor method to set the -</span><span class='nx-comment'># value of instance variable "a" -</span>f1 a <span class='nx-keyword'>set</span> 100 - -<span class='nx-comment'># Use the accessor method to unset the -</span><span class='nx-comment'># value of instance variable "a" -</span>f1 a <span class='nx-keyword'>unset</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>Similar to <code>variable</code>, properties can be defined in NX on the class -and on the object level.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># XOTcl provides no means to define -</span><span class='nx-comment'># configurable variables at the object -</span><span class='nx-comment'># level</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define class with a property for the class object -</span><span class='nx-comment'># named "cp". This is similar to "static variables" -</span><span class='nx-comment'># in some other object-oriented programming -</span><span class='nx-comment'># languages. -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - ... - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>property</span> cp 101 -} - -<span class='nx-comment'># Define object property "op" -</span> -<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>property</span> op 102 -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>NX supports <em>value constraints</em> (value-checkers) for object and method -parameters in an orthogonal manner. NX provides a predefined set of -value checkers, which can be extended by the application developer. -In NX, the <em>value checking is optional</em>. This means that it is possible to -develop e.g. which a large amount of value-checking and deploy the -script with value checking turned off, if the script is highly -performance sensitive.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># No value constraints for -</span><span class='nx-comment'># parameter available</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Predefined value constraints: -</span><span class='nx-comment'># object, class, alnum, alpha, ascii, boolean, -</span><span class='nx-comment'># control, digit, double, false, graph, integer, -</span><span class='nx-comment'># lower, parameter, print, punct, space, true, -</span><span class='nx-comment'># upper, wordchar, xdigit -</span><span class='nx-comment'># -</span><span class='nx-comment'># User defined value constraints are possible. -</span><span class='nx-comment'># All parameter value checkers can be turned on -</span><span class='nx-comment'># and off at runtime. -</span><span class='nx-comment'># -</span><span class='nx-comment'># Define a required boolean property "a" -</span><span class='nx-comment'># and an integer property "b" with a default. -</span><span class='nx-comment'># The first definition uses "properties", -</span><span class='nx-comment'># the second definition uses multiple -</span><span class='nx-comment'># "property" statements. -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo -properties { - a:boolean - {b:integer 1} -}</pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - <span class='nx-keyword'>:property</span> a:boolean - <span class='nx-keyword'>:property</span> {b:integer 1} -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>In XOTcl all configure parameters were <em>optional</em>. Required parameters have -to be passed to the constructor of the object.</p></div> -<div class="paragraph"><p>NX allows one to define <em>optional</em> and <em>required</em> configure parameters (as -well as method parameters). Therefore, configure parameters can be used -as the single mechanism to parametrize objects. It is in NX not -necessary (and per default not possible) to pass arguments to the -constructor.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Required parameter not available</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Required parameter: -</span><span class='nx-comment'># Define a required property "a" and a -</span><span class='nx-comment'># required boolean property "b" -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo -properties { - a:required - b:boolean,required -}</pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - <span class='nx-keyword'>:property</span> a:required - <span class='nx-keyword'>:property</span> b:boolean,required -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>NX supports in contrary to XOTcl to define the <em>multiplicity</em> of values -per parameter. In NX, one can specify that a parameter can accept the -value "" (empty) in addition to e.g. an integer, or one can specify that the -value is an empty or non-empty list of values via the multiplicity. For -every specified value, the value checkers are applied.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Multiplicity for parameter -</span><span class='nx-comment'># not available</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Parameter with multiplicity -</span><span class='nx-comment'># ints is a list of integers, with default -</span><span class='nx-comment'># objs is a non-empty list of objects -</span><span class='nx-comment'># obj is a single object, maybe empty -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo -properties { - {ints:integer,0..n <span class='nx-string'>""</span>} - objs<span class='nx-keyword'>:object</span>,1..n - obj<span class='nx-keyword'>:object</span>,0..1 -}</pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - <span class='nx-keyword'>:property</span> {ints:integer,0..n <span class='nx-string'>""</span>} - <span class='nx-keyword'>:property</span> objs<span class='nx-keyword'>:object</span>,1..n - <span class='nx-keyword'>:property</span> obj<span class='nx-keyword'>:object</span>,0..1 -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>For the implementation of variables and properties, NX uses slot -objects, which are an extension to the <code>-slots</code> already available in -XOTcl. While very for every <code>property</code> in NX, a slot object is created, -for performance reasons, not every <code>variable</code> has a slot associated.</p></div> -<div class="paragraph"><p>When a property is created, NX does actually three things:</p></div> -<div class="olist arabic"><ol class="arabic"> -<li> -<p> -Create a slot object, which can be specified in more detail - using the init-block of the slot object -</p> -</li> -<li> -<p> -Create a parameter definition for the initialization of the - object (usable via a non-positional parameter during object - creation), and -</p> -</li> -<li> -<p> -register optionally an accessor function (setter), for which the usual - protection levels (<code>public</code>, <code>protected</code> or <code>private</code>) can be used. -</p> -</li> -</ol></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define parameters via slots -</span> -<span class='nx-keyword'>Class</span> Foo -slots { - <span class='nx-keyword'>Attribute</span> a - <span class='nx-keyword'>Attribute</span> b -default 1 -} - -<span class='nx-comment'># Create instance of the class Foo -</span><span class='nx-comment'># and provide a value for instance -</span><span class='nx-comment'># variable "a" -</span>Foo f1 -a 0 - -<span class='nx-comment'># Object f1 has a == 0 and b == 1</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Configurable parameters specified via the -</span><span class='nx-comment'># method "property" (supports method -</span><span class='nx-comment'># modifiers and scripted configuration; -</span><span class='nx-comment'># see below) -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { - <span class='nx-keyword'>:property</span> a - <span class='nx-keyword'>:property</span> {b 1} -} - -<span class='nx-comment'># Create instance of the class Foo and -</span><span class='nx-comment'># provide a value for instance variable "a" -</span>Foo <span class='nx-keyword'>create</span> f1 -a 0 - -<span class='nx-comment'># Object f1 has a == 0 and b == 1</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>Since the slots are objects, the slot objects can be configured and -parametrized like every other object in NX. Slot objects can be -provided with a scripted initialization as well. We show first the -definition of properties similar to the functionality provided as well -by XOTcl and show afterwards how to use value constraints, optional -parameters, etc. in NX.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define parameter with an -</span><span class='nx-comment'># attribute-specific type checker -</span> -<span class='nx-keyword'>Class</span> Person -slots { - <span class='nx-keyword'>Attribute</span> <span class='nx-keyword'>create</span> sex -type <span class='nx-string'>"sex"</span> { - <span class='nx-keyword'>my</span> <span class='nx-keyword'>proc</span> type=sex {name value} { - <span class='nx-keyword'>switch</span> -glob <span class='nx-variable'>$value</span> { - m* {<span class='nx-keyword'>return</span> m} - f* {<span class='nx-keyword'>return</span> f} - default { - <span class='nx-keyword'>error</span> <span class='nx-string'>"expected sex but got $value"</span> - } - } - } - } -}</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Configure parameter with scripted -</span><span class='nx-comment'># definition (init-block), defining a -</span><span class='nx-comment'># property specific type checker -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Person { - <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>public</span> sex:sex,convert { - - <span class='nx-comment'># define a converter to standardize representation -</span> <span class='nx-keyword'>:object</span> <span class='nx-keyword'>method</span> type=sex {name value} { - <span class='nx-keyword'>switch</span> -glob <span class='nx-variable'>$value</span> { - m* {<span class='nx-keyword'>return</span> m} - f* {<span class='nx-keyword'>return</span> f} - default {<span class='nx-keyword'>error</span> <span class='nx-string'>"expected sex but got $value"</span>} - } - } - - } -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>The parameters provided by a class for the initialization of -instances can be introspected via querying the parameters -of the method create: <code>/cls/ info lookup parameters create</code> -(see <a href="#info_configure_parameter">[info_configure_parameter]</a>).</p></div> -</div> -<div class="sect3"> -<h4 id="_delete_variable_handlers">2.4.2. Delete Variable Handlers</h4> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># No syntactic support for deleting -</span><span class='nx-comment'># variable handlers</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Like deletion of Methods: -</span><span class='nx-comment'># Delete on the object, where the -</span><span class='nx-comment'># variable handler is defined. -</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>property</span> <span class='nx-placeholder'>/name/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>property</span> <span class='nx-placeholder'>/name/</span> - -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>variable</span> <span class='nx-placeholder'>/name/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>variable</span> <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_method_parameters">2.4.3. Method Parameters</h4> -<div class="paragraph"><p>Method parameters are used to specify the interface of a single method -(what kind of values may be passed to a method, what default values -are provided etc.). The method parameters specifications in XOTcl 1 -were limited and allowed only value constraints for non positional -arguments.</p></div> -<div class="paragraph"><p>NX and XOTcl 2 provide value constraints for all kind of method parameters. -While XOTcl 1 required non-positional arguments to be listed in front of -positional arguments, this limitation is lifted in XOTcl 2.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define method foo with non-positional -</span><span class='nx-comment'># parameters (x, y and y) and positional -</span><span class='nx-comment'># parameter (a and b) -</span> -<span class='nx-keyword'>Class</span> C -C instproc foo { - -x:integer - -y:required - -z - a - b -} { - <span class='nx-comment'># ... -</span>} -C <span class='nx-keyword'>create</span> c1 - -<span class='nx-comment'># invoke method foo -</span>c1 foo -x 1 -y a 2 3</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define method foo with -</span><span class='nx-comment'># non-positional parameters -</span><span class='nx-comment'># (x, y and y) and positional -</span><span class='nx-comment'># parameter (a and b) -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo { - -x:integer - -y:required - -z - a - b - } { - <span class='nx-comment'># ... -</span> } - <span class='nx-keyword'>:create</span> c1 -} -<span class='nx-comment'># invoke method foo -</span>c1 foo -x 1 -y a 2 3</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Only leading non-positional -</span><span class='nx-comment'># parameters are available; no -</span><span class='nx-comment'># optional positional parameters, -</span><span class='nx-comment'># no value constraints on -</span><span class='nx-comment'># positional parameters, -</span><span class='nx-comment'># no multiplicity, ...</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define various forms of parameters -</span><span class='nx-comment'># not available in XOTcl 1 -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-comment'># trailing (or interleaved) non-positional -</span> <span class='nx-comment'># parameters -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> m1 {a b -x:integer -y} { - <span class='nx-comment'># ... -</span> } - - <span class='nx-comment'># positional parameters with value constraints -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> m2 {a:integer b:boolean} { - <span class='nx-comment'>#... -</span> } - - <span class='nx-comment'># optional positional parameter (trailing) -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> <span class='nx-keyword'>set</span> {varName value:optional} { - <span class='nx-comment'># .... -</span> } - - <span class='nx-comment'># parameter with multiplicity -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> m3 {-objs<span class='nx-keyword'>:object</span>,1..n c<span class='nx-keyword'>:class</span>,0..1} { - <span class='nx-comment'># ... -</span> } - - <span class='nx-comment'># In general, the same list of value -</span> <span class='nx-comment'># constraints as for configure parameter is -</span> <span class='nx-comment'># available (see above). -</span> <span class='nx-comment'># -</span> <span class='nx-comment'># User defined value constraints are -</span> <span class='nx-comment'># possible. All parameter value checkers -</span> <span class='nx-comment'># can be turned on and off. -</span>}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_return_value_checking">2.4.4. Return Value Checking</h4> -<div class="paragraph"><p><em>Return value checking</em> is a functionality available in the Next -Scripting Framework, that was not yet available in XOTcl 1. A return -value checker assures that a method returns always a value satisfying -some value constraints. Return value checkers can be defined on all -forms of methods (scripted or C-implemented). Like for other value -checkers, return value checkers can be turned on and off.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># No return value checking -</span><span class='nx-comment'># available</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define method foo with non-positional -</span><span class='nx-comment'># parameters (x, y and y) and positional -</span><span class='nx-comment'># parameter (a and b) -</span> -<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { - - <span class='nx-comment'># Define method foo which returns an -</span> <span class='nx-comment'># integer value -</span> <span class='nx-keyword'>:method</span> foo -returns integer {-x:integer} { - <span class='nx-comment'># ... -</span> } - - <span class='nx-comment'># Define an alias for the Tcl command ::incr -</span> <span class='nx-comment'># and assure, it always returns an integer -</span> <span class='nx-comment'># value -</span> <span class='nx-keyword'>:alias</span> <span class='nx-keyword'>incr</span> -returns integer ::incr - - <span class='nx-comment'># Define a forwarder that has to return an -</span> <span class='nx-comment'># integer value -</span> <span class='nx-keyword'>:forward</span> ++ -returns integer ::expr 1 + - - <span class='nx-comment'># Define a method that has to return a -</span> <span class='nx-comment'># non-empty list of objects -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> instances {} \ - -returns <span class='nx-keyword'>object</span>,1..n { - <span class='nx-keyword'>return</span> [<span class='nx-keyword'>:info</span> instances] - } -}</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_interceptors">2.5. Interceptors</h3> -<div class="paragraph"><p>XOTcl and NX allow the definition of the same set of interceptors, -namely class- and object-level mixins and class- and object-level -filters. The primary difference in NX is the naming, since NX abandons -the prefix "inst" from the names of instance specific method, but uses -the modifier <code>object</code>" for object specific methods.</p></div> -<div class="paragraph"><p>Therefore, in NX, if a <code>mixin</code> is registered on a class-level, it is -applicable for the instances (a per-class mixin), and if and <code>object -mixin</code> is registered, it is a per-object mixin. In both cases, the -term <code>mixin</code> is used, in the second case with the modifier -<code>object</code>. As in all other cases, one can register the same way a -per-object mixin on a plain object or on a class object.</p></div> -<div class="sect3"> -<h4 id="_register_mixin_classes_and_mixin_guards">2.5.1. Register Mixin Classes and Mixin Guards</h4> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> instmixin ... -<span class='nx-placeholder'>/cls/</span> instmixinguard /<span class='nx-keyword'>mixin</span>/ <span class='nx-placeholder'>?condition?</span> - -<span class='nx-comment'># Query per-class mixin -</span><span class='nx-placeholder'>/cls/</span> instmixin</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Register/clear per-class mixin and guard for -</span><span class='nx-comment'># a class -</span> -<span class='nx-placeholder'>/cls/</span> mixins add|<span class='nx-keyword'>set</span>|clear ... -<span class='nx-placeholder'>/cls/</span> mixins <span class='nx-keyword'>guard</span> /<span class='nx-keyword'>mixin</span>/ <span class='nx-placeholder'>?condition?</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>configure</span> -mixin ... - -<span class='nx-comment'># Query per-class mixins -</span><span class='nx-placeholder'>/cls/</span> mixins get -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>cget</span> -mixins - -<span class='nx-comment'># Query per-class mixins (without guards) -</span><span class='nx-placeholder'>/cls/</span> mixins classes</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>mixin</span> ... -<span class='nx-placeholder'>/obj/</span> mixinguard /<span class='nx-keyword'>mixin</span>/ <span class='nx-placeholder'>?condition?</span> - -<span class='nx-comment'># Query per-object mixins -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>mixin</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Register/clear per-object mixin and guard for -</span><span class='nx-comment'># an object -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> mixins add|<span class='nx-keyword'>set</span>|clear ... -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> mixins <span class='nx-keyword'>guard</span> /<span class='nx-keyword'>mixin</span>/ <span class='nx-placeholder'>?condition?</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>configure</span> -object-mixins ... - -<span class='nx-comment'># Query per-object mixin -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> mixins get -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>cget</span> -object-mixin - -<span class='nx-comment'># Query per-object mixins (without guards) -</span><span class='nx-placeholder'>/cls/</span> mixins classes</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_register_filters_and_filter_guards">2.5.2. Register Filters and Filter Guards</h4> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Register per-class filter and guard for -</span><span class='nx-comment'># a class -</span><span class='nx-placeholder'>/cls/</span> instfilter ... -<span class='nx-placeholder'>/cls/</span> instfilterguard /<span class='nx-keyword'>filter</span>/ <span class='nx-placeholder'>?condition?</span> - -<span class='nx-comment'># Query per-class filter -</span><span class='nx-placeholder'>/cls/</span> instfilter</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Register/clear per-class filter and guard for -</span><span class='nx-comment'># a class -</span> -<span class='nx-placeholder'>/cls/</span> filters add|<span class='nx-keyword'>set</span>|clear ... -<span class='nx-placeholder'>/cls/</span> filters <span class='nx-keyword'>guard</span> /<span class='nx-keyword'>filter</span>/ <span class='nx-placeholder'>?condition?</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>configure</span> -filters ... - -<span class='nx-comment'># Query per-class filters -</span><span class='nx-placeholder'>/cls/</span> filters get -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>cget</span> -filters - -<span class='nx-comment'># Query per-class filters (without guards) -</span><span class='nx-placeholder'>/cls/</span> filters <span class='nx-keyword'>methods</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>filter</span> ... -<span class='nx-placeholder'>/obj/</span> filterguard /<span class='nx-keyword'>filter</span>/ <span class='nx-placeholder'>?condition?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Register(clear per-object filter and guard for -</span><span class='nx-comment'># an object -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> filters add|<span class='nx-keyword'>set</span>|clear ... -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> filters <span class='nx-keyword'>guard</span> /<span class='nx-keyword'>filter</span>/ <span class='nx-placeholder'>?condition?</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>configure</span> -object-filters ... - -<span class='nx-comment'># Query per-object filters -</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>object</span> filters get -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>cget</span> -object-filters - -<span class='nx-comment'># Query per-object filters (without guards) -</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>object</span> filters <span class='nx-keyword'>methods</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_introspection">2.6. Introspection</h3> -<div class="paragraph"><p>In general, introspection in NX became more orthogonal and less -dependent on the type of the method. In XOTcl it was e.g. necessary -that a developer had to know, whether a method is e.g. scripted or not -and has to use accordingly different sub-methods of <code>info</code>.</p></div> -<div class="paragraph"><p>In NX, one can use e.g. always <code>info method</code> with a subcommand and the -framework tries to hide the differences as far as possible. So, one -can for example obtain with <code>info method parameter</code> the parameters of -scripted and C-implemented methods the same way, one can get the -definition of all methods via <code>info method definition</code> and one can get -an manual-like interface description via <code>info method -syntax</code>. In addition, NX provides means to query the type of -a method, and NX allows one to filter by the type of the method.</p></div> -<div class="sect3"> -<h4 id="_list_sub_and_superclass_relations">2.6.1. List sub- and superclass relations</h4> -<div class="paragraph"><p>While XOTcl used singular words for introspecting sub- and superclass -relations, NX uses plural word to indicate that potentially a list of -values is returned.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>superclass</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> superclasses <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> subclass <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> subclasses -type setter <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_methods_defined_by_classes">2.6.2. List methods defined by classes</h4> -<div class="paragraph"><p>While XOTcl uses different names for obtaining different kinds of -methods defined by a class, NX uses <code>info methods</code> in an orthogonal -manner. NX allows as well to use the call protection to filter the -returned methods.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instcommands <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instparametercmd <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type setter <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instprocs <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type scripted <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type <span class='nx-keyword'>alias</span> <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type forwarder <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type <span class='nx-keyword'>object</span> <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -callprotection <span class='nx-keyword'>public</span>|<span class='nx-keyword'>protected</span> ...</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_methods_defined_by_objects">2.6.3. List methods defined by objects</h4> -<div class="paragraph"><p>While XOTcl uses different names for obtaining different kinds of -methods defined by an object, NX uses <code>info methods</code> in an orthogonal -manner. NX allows as well to use the call protection to filter the -returned methods.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> commands <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> parametercmd <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type setter <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> procs <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type scripted <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type <span class='nx-keyword'>alias</span> <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type forwarder <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type <span class='nx-keyword'>object</span> <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -callprotection <span class='nx-keyword'>public</span>|<span class='nx-keyword'>protected</span> ...</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_check_existence_of_a_method">2.6.4. Check existence of a method</h4> -<div class="paragraph"><p>NX provides multiple ways of checking, whether a method exists; one -can use <code>info method exists</code> to check, if a given method exists -(return boolean), or one can use <code>info methods ?pattern?</code>, where -<code>pattern</code> might be a single method name without wild-card -characters. The method <code>info methods ?pattern?</code> returns a list of -matching names, which might be empty. These different methods appear -appropriate depending on the context.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>/obj|cls/ <span class='nx-keyword'>info</span> \ - [inst](commands|procs|parametercmd) \ - <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> exists <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> exists <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_callable_methods">2.6.5. List callable methods</h4> -<div class="paragraph"><p>In order to obtain for an object the set of artefacts defined in the - class hierarchy, NX uses <code>info lookup</code>. One can either lookup methods - (via <code>info lookup methods</code>) or slots (via <code>info lookup slots</code>). The - plural term refers to a potential set of return values.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> <span class='nx-keyword'>methods</span> ... <span class='nx-placeholder'>?pattern?</span> -<span class='nx-comment'># Returns list of method names</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># List only application specific methods -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> <span class='nx-keyword'>methods</span> -source application ... <span class='nx-placeholder'>?pattern?</span> -<span class='nx-comment'># Returns list of method names</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Options for 'info methods' -</span><span class='nx-comment'># -</span><span class='nx-comment'># -incontext -</span><span class='nx-comment'># -nomixins</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Options for 'info lookup methods' -</span><span class='nx-comment'># -</span><span class='nx-comment'># -source ... -</span><span class='nx-comment'># -callprotection ... -</span><span class='nx-comment'># -incontext -</span><span class='nx-comment'># -type ... -</span><span class='nx-comment'># -nomixins</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># List slot objects defined for obj -</span><span class='nx-comment'># -source might be all|application|baseclasses -</span><span class='nx-comment'># -type is the class of the slot object -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> slots <span class='nx-placeholder'>?-type ...?</span> <span class='nx-placeholder'>?-source ...?</span> <span class='nx-placeholder'>?pattern?</span> - -<span class='nx-comment'># Returns list of slot objects</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># List registered filters -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> filters -order <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span> - -<span class='nx-comment'># List registered mixins -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> mixins -heritage <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># List registered filters -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> filters <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span> - -<span class='nx-comment'># List registered mixins -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> mixins <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_object_class_where_a_specified_method_is_defined">2.6.6. List object/class where a specified method is defined</h4> -<div class="paragraph"><p><code>info lookup</code> can be used as well to determine, where exactly an - artefact is located. One can obtain this way a method handle, where -a method or filter is defined.</p></div> -<div class="paragraph"><p>The concept of a <em>method-handle</em> is new in NX. The method-handle -can be used to obtain more information about the method, such as -e.g. the definition of the method.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> procsearch <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> <span class='nx-keyword'>method</span> <span class='nx-placeholder'>/methodName/</span> -<span class='nx-comment'># Returns method-handle</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> filtersearch <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> <span class='nx-keyword'>filter</span> <span class='nx-placeholder'>/methodName/</span> -<span class='nx-comment'># Returns method-handle</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_definition_of_scripted_methods">2.6.7. List definition of scripted methods</h4> -<div class="paragraph"><p>XOTcl contains a long list of <code>info</code> subcommands for different kinds of -methods and for obtaining more detailed information about these -methods.</p></div> -<div class="paragraph"><p>In NX, this list of <code>info</code> subcommands is much shorter and more -orthogonal. For example <code>info method definition</code> can be used to obtain -with a single command the full definition of a <em>scripted method</em>, and -furthermore, it works as well the same way to obtain e.g. the -definition of a <em>forwarder</em> or an <em>alias</em>.</p></div> -<div class="paragraph"><p>While XOTcl uses different names for info options for objects and -classes (using the prefix "inst" for instance specific method), NX -uses for object specific method the modifier <code>object</code>. For definition -of class object specific methods, use the modifier <code>object</code> as usual.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> definition <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> definition <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instbody <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> body <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> body <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> body <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instargs <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> args <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> args <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> args <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instnonposargs <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> args <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> parameter <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> parameter <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instdefault <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> default <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># not needed, part of -</span><span class='nx-comment'># "info ?object? method parameter"</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instpre <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> pre <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> precondition <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> precondition <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instpost <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> post <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> postcondition <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> postcondition <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -<div class="paragraph"><p>Another powerful introspection option in NX is <code>info ?object? method -syntax</code> which obtains a representation of the parameters of a -method in the style of Tcl man pages (regardless of the kind of -method).</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> syntax <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> syntax <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="info_configure_parameter">2.6.8. List Configure Parameters</h4> -<div class="paragraph"><p>The way, how newly created objects can be configured is determined in NX -via properties. The configuration happens during creation via the -methods <code>create</code> or <code>new</code> or during runtime via <code>configure</code>. These -methods have therefore virtual argument lists, depending on the object -or class on which they are applied.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Return the parameters applicable to -</span><span class='nx-comment'># the create method of a certain class. -</span><span class='nx-comment'># class can be configured. A pattern can -</span><span class='nx-comment'># be used to filter the results. -</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> parameters <span class='nx-keyword'>create</span> ?<span class='nx-placeholder'>/pattern/</span>? - -<span class='nx-comment'># Return in the result in documentation syntax -</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>create</span> ?<span class='nx-placeholder'>/pattern/</span>? - -<span class='nx-comment'># "info lookup parameters configure" returns -</span><span class='nx-comment'># parameters available for configuring the -</span><span class='nx-comment'># current object (might contain object -</span><span class='nx-comment'># specific information) -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> parameters <span class='nx-keyword'>configure</span> <span class='nx-placeholder'>?pattern?</span> - -<span class='nx-comment'># "info lookup configure syntax" returns syntax of -</span><span class='nx-comment'># a call to configure in the Tcl parameter syntax -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>configure</span> - -<span class='nx-comment'># Obtain information from a parameter -</span><span class='nx-comment'># (as e.g. returned from "info lookup -</span><span class='nx-comment'># parameters configure"). -</span> -nsf::parameter::info name <span class='nx-placeholder'>/parameter/</span> -nsf::parameter::info syntax <span class='nx-placeholder'>/parameter/</span> -nsf::parameter::info type <span class='nx-placeholder'>/parameter/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_variable_declarations_property_and_variable">2.6.9. List Variable Declarations (property and variable)</h4> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># obtain parameter definitions defined -</span><span class='nx-comment'># for a class -</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> parameter</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># "info variables" returns handles of -</span><span class='nx-comment'># properties and variables defined by this -</span><span class='nx-comment'># class or object -</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> variables <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> variables <span class='nx-placeholder'>?pattern?</span> - -<span class='nx-comment'># "info lookup variables" returns handles -</span><span class='nx-comment'># of variables and properties applicable -</span><span class='nx-comment'># for the current object (might contain -</span><span class='nx-comment'># object specific information) -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> variables <span class='nx-placeholder'>/pattern/</span> - -<span class='nx-comment'># "info variable" lists details about a -</span><span class='nx-comment'># single property or variable. -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>variable</span> definition <span class='nx-placeholder'>/handle/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>variable</span> name <span class='nx-placeholder'>/handle/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>variable</span> parameter <span class='nx-placeholder'>/handle/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_slots">2.6.10. List Slots</h4> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Return list of slots objects defined on the -</span><span class='nx-comment'># object or class -</span><span class='nx-comment'># -</span><span class='nx-comment'># -source might be all|application|baseclasses -</span><span class='nx-comment'># -type is the class of the slot object -</span><span class='nx-comment'># -closure includes slots of superclasses -</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> slots \ - <span class='nx-placeholder'>?-type value?</span> <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?-source value?</span> <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> slots <span class='nx-placeholder'>?-type ...?</span> <span class='nx-placeholder'>?pattern?</span> - -<span class='nx-comment'># List reachable slot objects defined for obj -</span><span class='nx-comment'># -source might be all|application|baseclasses -</span><span class='nx-comment'># -type is the class of the slot object -</span><span class='nx-comment'># Returns list of slot objects. -</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> slots \ - <span class='nx-placeholder'>?-type ...?</span> <span class='nx-placeholder'>?-source ... ?</span>pattern? - -<span class='nx-comment'># Obtain definition, name or parameter from -</span><span class='nx-comment'># slot object -</span> -<span class='nx-placeholder'>/slotobj/</span> definition -<span class='nx-placeholder'>/slotobj/</span> name -<span class='nx-placeholder'>/slotobj/</span> parameter</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_filter_or_mixins">2.6.11. List Filter or Mixins</h4> -<div class="paragraph"><p>In NX all introspection options for filters are provided via -<code>info filters</code> and all introspection options for mixins are -provided via <code>info mixins</code>.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>filter</span> <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-order?</span> <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> filterguard <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> filters \ - <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instfilter \ - <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-order?</span> <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instfilterguard <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> filters \ - <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>mixin</span> <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-order ?</span>pattern? -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> mixinguard <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> mixins \ - <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instmixin \ - <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-order?</span> <span class='nx-placeholder'>?pattern?</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instmixinguard <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixins \ - <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-heritage?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_definition_of_methods_defined_by_aliases_setters_or_forwarders">2.6.12. List definition of methods defined by aliases, setters or forwarders</h4> -<div class="paragraph"><p>As mentioned earlier, <code>info method definition</code> can be used on every -kind of method. The same call can be used to obtain the definition of -a scripted method, a method-alias, a forwarder or a setter method.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> definition <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> definition <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_method_handles">2.6.13. List Method-Handles</h4> -<div class="paragraph"><p>NX supports <em>method-handles</em> to provide means to obtain further -information about a method or to change maybe some properties of a -method. When a method is created, the method creating method returns -the method handle to the created method.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># List the method handle of the specified method, -</span><span class='nx-comment'># can be used e.g. for aliases. "handle" is the short -</span><span class='nx-comment'># form of "definitionhandle". -</span><span class='nx-comment'># -</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> handle <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> handle <span class='nx-placeholder'>/methodName/</span> -<span class='nx-comment'># -</span><span class='nx-comment'># For ensemble methods (method name contains -</span><span class='nx-comment'># spaces) one can query as well the registration -</span><span class='nx-comment'># handle, which is the handle to the root of the -</span><span class='nx-comment'># ensemble; the definition handle points to the -</span><span class='nx-comment'># leaf of the ensemble. -</span><span class='nx-comment'># -</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> registrationhandle <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> registrationhandle <span class='nx-placeholder'>/methodName/</span> -<span class='nx-comment'># -</span><span class='nx-comment'># For aliases, one can query the original -</span><span class='nx-comment'># definition via "info method origin" -</span><span class='nx-comment'># -</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> origin <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> origin <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_type_of_a_method">2.6.14. List type of a method</h4> -<div class="paragraph"><p>The method <code>info ?object? method type</code> is new in NX to obtain the type of the -specified method.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> type <span class='nx-placeholder'>/methodName/</span> -<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> type <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_list_the_scope_of_mixin_classes">2.6.15. List the scope of mixin classes</h4> -<div class="paragraph"><p>NX provides a richer set of introspection options to obtain -information, where mixins classes are mixed into.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># List objects, where /cls/ is a -</span><span class='nx-comment'># per-object mixin -</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof -scope <span class='nx-keyword'>object</span> <span class='nx-placeholder'>?-closure?</span> \ - <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instmixinof <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># List classes, where /cls/ is a per-class mixin -</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof -scope <span class='nx-keyword'>class</span> <span class='nx-placeholder'>?-closure?</span> \ - <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># List objects and classes, where /cls/ is -</span><span class='nx-comment'># either a per-object or a per-class mixin -</span> -<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof -scope all <span class='nx-placeholder'>?-closure?</span> \ - <span class='nx-placeholder'>?pattern?</span></pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_check_properties_of_object_and_classes">2.6.16. Check properties of object and classes</h4> -<div class="paragraph"><p>Similar as noted before, NX uses rather a hierarchical approach of -naming using multiple layers of subcommands).</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> istype <span class='nx-placeholder'>/sometype/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Check if object is a subtype of some class -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> has type <span class='nx-placeholder'>/sometype/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> ismixin <span class='nx-placeholder'>/cls/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Check if object has the specified mixin registered -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> has <span class='nx-keyword'>mixin</span> <span class='nx-placeholder'>/cls/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> isclass ?<span class='nx-placeholder'>/cls/</span>?</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Check if object is an NX class -</span><span class='nx-placeholder'>/obj/</span> has type ::nx::Class - -<span class='nx-comment'># Check if object is a class in one of the -</span><span class='nx-comment'># NSF object systems -</span>::nsf::is <span class='nx-keyword'>class</span> <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> ismetaclass <span class='nx-placeholder'>/cls/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Check if class is an NX metaclass -</span><span class='nx-keyword'>expr</span> {[<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> heritage ::nx::Class] ne <span class='nx-string'>""</span>} - -<span class='nx-comment'># Check if object is a metaclass in one of the -</span><span class='nx-comment'># NSF object systems -</span>::nsf::is <span class='nx-keyword'>metaclass</span> <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Check if object is a baseclass of an object system -</span>::nsf::is baseclass <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Return name of object (without namespace prefix) -</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> name</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span>::exists <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Check for existence of object (nsf primitive) -</span>::nsf::object::exists <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect3"> -<h4 id="_call_stack_introspection">2.6.17. Call-stack Introspection</h4> -<div class="paragraph"><p>Call-stack introspection is very similar in NX and XOTcl. NX uses for -subcommand the term <code>current</code> instead of <code>self</code>, since <code>self</code> has a -strong connotation to the current object. The term <code>proc</code> is renamed -by <code>method</code>.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span></pre></div></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> <span class='nx-keyword'>object</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> <span class='nx-keyword'>class</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> <span class='nx-keyword'>class</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> args</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> args</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> <span class='nx-keyword'>proc</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> <span class='nx-keyword'>method</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> callingclass</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> calledclass</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> callingobject</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> callingobject</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> callingproc</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> callingmethod</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> calledclass</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> calledclass</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> calledproc</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> calledmethod</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> isnextcall</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> isnextcall</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> <span class='nx-keyword'>next</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Returns method-handle of the -</span><span class='nx-comment'># method to be called via "next" -</span><span class='nx-keyword'>current</span> <span class='nx-keyword'>next</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> filterreg</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Returns method-handle of the -</span><span class='nx-comment'># filter method -</span><span class='nx-keyword'>current</span> filterreg</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> callinglevel</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> callinglevel</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>self</span> activelevel</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>current</span> activelevel</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_other_predefined_methods">2.7. Other Predefined Methods</h3> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> requireNamespace</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>require</span> <span class='nx-keyword'>namespace</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>require</span> <span class='nx-keyword'>method</span></pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect2"> -<h3 id="_dispatch_aliases_etc">2.8. Dispatch, Aliases, etc.</h3> -<div class="paragraph"><p>todo: to be done or omitted</p></div> -</div> -<div class="sect2"> -<h3 id="_assertions">2.9. Assertions</h3> -<div class="paragraph"><p>In contrary to XOTcl, NX provides no pre-registered methods for -assertion handling. All assertion handling can e performed via the -Next Scripting primitive <code>nsf::method::assertion</code>.</p></div> -<div class="tableblock"> -<table rules="all" -width="100%" -frame="void" -cellspacing="0" cellpadding="4"> -<col width="50%" /> -<col width="50%" /> -<thead> -<tr> -<th align="left" valign="middle">XOTcl </th> -<th align="left" valign="middle">Next Scripting Language</th> -</tr> -</thead> -<tbody> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> check <span class='nx-placeholder'>/checkoptions/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/obj/</span> check <span class='nx-placeholder'>/checkoptions/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> check</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/obj/</span> check</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span>-invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> invar</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span>-invar</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> instinvar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>class</span>-invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instinvar</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>class</span>-invar</pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>object</span>-invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> -</tr> -<tr> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> invar</pre></div></div></div></td> -<td align="left" valign="middle"><div><div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>object</span>-invar</pre></div></div></div></td> -</tr> -</tbody> -</table> -</div> -</div> -<div class="sect2"> -<h3 id="_method_protection">2.10. Method Protection</h3> -<div class="paragraph"><p>As described <a href="#method-protect-example">above</a>, NX supports method -protection via the method modifiers <code>protected</code> and <code>public</code>. A -protected method can be only called from an object of that class, -while public methods can be called from every object. The method -protection can be used to every kind of method, such as e.g. scripted -methods, aliases, forwarders, or accessors. For invocations, -the most specific definition (might be a mixin) is used for -determining the protection.</p></div> -</div> -</div> -</div> -<div class="sect1"> -<h2 id="_incompatibilities_between_xotcl_1_and_xotcl_2">3. Incompatibilities between XOTcl 1 and XOTcl 2</h2> -<div class="sectionbody"> -<div class="sect2"> -<h3 id="_resolvers_2">3.1. Resolvers</h3> -<div class="paragraph"><p>The resolvers (variable resolvers, function resolvers) of the Next -Scripting Framework are used as well within XOTcl 2. When variable -names or method names starting with a single colon are used in XOTcl 1 -scripts, conflicts will arise with the resolver. These names must be -replaced.</p></div> -</div> -<div class="sect2"> -<h3 id="_parameters_2">3.2. Parameters</h3> -<div class="paragraph"><p>The following changes for parameters could be regarded as bug-fixes.</p></div> -<div class="sect3"> -<h4 id="_parameter_usage_without_a_value">3.2.1. Parameter usage without a value</h4> -<div class="paragraph"><p>In XOTcl 1, it was possible to call a parameter method during object -creation via the dash-interface without a value (in the example below <code>-x</code>).</p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># XOTcl example -</span> -<span class='nx-keyword'>Class</span> Foo -parameter {x y} -Foo f1 -x -y 1</pre></div></div> -<div class="paragraph"><p>Such cases are most likely mistakes. All parameter configurations in XOTcl 2 require an argument.</p></div> -</div> -<div class="sect3"> -<h4 id="_ignored_parameter_definitions">3.2.2. Ignored Parameter definitions</h4> -<div class="paragraph"><p>In XOTcl 1, a more specific parameter definition without a default was ignored -when a more general parameter definition with a default was -present. In the example below, the object <code>b1</code> contained in XOTcl 1 -incorrectly the parameter <code>x</code> (set via default from <code>Foo</code>), while in -XOTcl 2, the variable won’t be set.</p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># XOTcl example -</span> -<span class='nx-keyword'>Class</span> Foo -parameter {{x 1}} -<span class='nx-keyword'>Class</span> Bar -superclass Foo -parameter x -Bar b1</pre></div></div> -</div> -<div class="sect3"> -<h4 id="_changing_classes_and_superclasses">3.2.3. Changing classes and superclasses</h4> -<div class="paragraph"><p>NX does not define the methods <code>class</code> and <code>superclass</code> (like XOTcl), but allows one to -alter all object/class relations (including -class/superclass/object-mixin/…) -<code>nsf::relation::set</code>. The class and superclass can be certainly queried -in all variants with <code>info class</code> or <code>info superclasses</code>.</p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># NX example -</span> -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Foo -Foo <span class='nx-keyword'>create</span> f1 - -<span class='nx-comment'># now alter the class of object f1 -</span>nsf::relation::set f1 <span class='nx-keyword'>class</span> ::nx::Object</pre></div></div> -</div> -<div class="sect3"> -<h4 id="_overwriting_procs_methods_with_objects_and_vice_versa">3.2.4. Overwriting procs/methods with objects and vice versa</h4> -<div class="paragraph"><p>NSF is now more conservative on object/method creation. In contrary to -XOTcl 1 NSF does not allow one to redefined a pre-existing command -(e.g. "set") with an object and vice versa. Like in XOTcl 1, -preexisting objects and classes con be redefined (necessary for -reloading objects/classes in a running interpreter).</p></div> -</div> -<div class="sect3"> -<h4 id="_info_heritage">3.2.5. Info heritage</h4> -<div class="paragraph"><p><code>info heritage</code> returns in XOTcl 1 the transitive superclass -hierarchy, which is equivalent with <code>info superclasses -closure</code> and -therefore not necessary. In XOTcl 2 (and NX), <code>info heritage</code> includes -as well the transitive per-class mixins.</p></div> -</div> -</div> -<div class="sect2"> -<h3 id="_slots">3.3. Slots</h3> -<div class="paragraph"><p>All slot objects (also XOTcl slot objects) are now next-scripting -objects of baseclass <code>::nx::Slot</code>. The name of the experimental -default-setter <code>initcmd</code> was changed to <code>defaultcmd</code>. Code directly -working on the slots objects has to be adapted.</p></div> -</div> -<div class="sect2"> -<h3 id="_obsolete_commands">3.4. Obsolete Commands</h3> -<div class="paragraph"><p>Parameter-classes were rarely used and have been replaced by the more -general object parametrization. Therefore, <code>cl info parameterclass</code> has -been removed.</p></div> -</div> -<div class="sect2"> -<h3 id="_stronger_checking">3.5. Stronger Checking</h3> -<div class="paragraph"><p>The Next Scripting Framework performs stronger checking than XOTcl 1 -For example, the requiredness of slots in XOTcl 1 was just a -comment, while XOTcl 2 enforces it.</p></div> -</div> -<div class="sect2"> -<h3 id="_exit_handlers">3.6. Exit Handlers</h3> -<div class="paragraph"><p>The exit handler interface changed from a method of <code>::xotcl::Object</code> -into the Tcl command <code>::nsf::exithandler</code>:</p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># NX example -</span>::nsf::exithandler <span class='nx-keyword'>set</span>|get|<span class='nx-keyword'>unset</span> <span class='nx-placeholder'>?arg?</span></pre></div></div> -</div> -</div> -</div> -</div> -<div id="footnotes"><hr /></div> -<div id="footer"> -<div id="footer-text"> -Version 2.2.0<br /> -Last updated 2019-04-19 00:25:17 CEST -</div> -</div> -</body> -</html> +</div> +</div> +<div id="content"> +<div id="preamble"> +<div class="sectionbody"> +<div class="sidebarblock"> +<div class="content"> +<div class="title">Abstract</div> +<div class="paragraph"><p>This document describes the differences between the Next Scripting +Language Framework and XOTcl 1. In particular, it presents a +migration guide from XOTcl 1 to NX, and presents potential +incompatibilities between XOTcl 1 and XOTcl 2.</p></div> +</div></div> +<div class="paragraph"><p>The Next Scripting Language (NX) is a successor of XOTcl 1 and is +based on 10 years of experience with XOTcl in projects containing +several hundert thousand lines of code. While XOTcl was the first +language designed to provide language support for design patterns, the +focus of the Next Scripting Framework and NX are on combining this +with Language Oriented Programming. In many respects, NX was designed +to ease the learning of the language by novices (by using a more +mainstream terminology, higher orthogonality of the methods, less +predefined methods), to improve maintainability (remove sources of +common errors) and to encourage developer to write better structured +programs (to provide interfaces) especially for large projects, where +many developers are involved.</p></div> +<div class="paragraph"><p>The Next Scripting Language is based on the Next Scripting Framework +which was developed based on the notion of language oriented +programming. The Next Scripting Frameworks provides C-level support +for defining and hosting multiple object systems in a single Tcl +interpreter. The whole definition of NX is fully scripted +(e.g. defined in <code>nx.tcl</code>). The Next Scripting Framework is shipped +with three language definitions, containing NX and XOTcl 2. Most of +the existing XOTcl 1 programs can be used without modification in the +Next Scripting Framework by using XOTcl 2. The Next Scripting +Framework requires Tcl 8.5 or newer.</p></div> +<div class="paragraph"><p>Although NX is fully scripted (as well as XOTcl 2), our benchmarks +show that scripts based on NX are often 2 or 4 times faster than the +counterparts in XOTcl 1. But speed was not the primary focus on the +Next Scripting Environment: The goal was primarily to find ways to +repackage the power of XOTcl in an easy to learn environment, highly +orthogonal environment, which is better suited for large projects, +trying to reduce maintenance costs.</p></div> +<div class="paragraph"><p>We expect that many user will find it attractive to upgrade +from XOTcl 1 to XOTcl 2, and some other users will upgrade to NX. +This document focuses mainly on the differences between XOTcl 1 and +NX, but addresses as well potential incompatibilities between XOTcl 1 +and XOTcl 2. For an introduction to NX, please consult the NX tutorial.</p></div> +</div> +</div> +<div class="sect1"> +<h2 id="_differences_between_xotcl_and_nx">1. Differences Between XOTcl and NX</h2> +<div class="sectionbody"> +<div class="paragraph"><p>The Next Scripting Framework supports <em>Language Oriented Programming</em> +by providing means to define potentially multiple object systems with +different naming and functionality in a single interpreter. This +makes the Next Scripting Framework a powerful instrument for defining +multiple languages such as e.g. domain specific languages. This focus +differs from XOTcl 1.</p></div> +<div class="paragraph"><p>Technically, the language framework approach means that the languages +implemented by the Next Scripting Framework (most prominently XOTcl 2 +and NX) are typically fully scripted and can be loaded via the usual +Tcl <code>package require</code> mechanism.</p></div> +<div class="paragraph"><p>Some of the new features below are provided by the Next Scripting +Framework, some are implemented via the script files for XOTcl 2 and +NX.</p></div> +<div class="sect2"> +<h3 id="_features_of_nx">1.1. Features of NX</h3> +<div class="paragraph"><p>In general, the Next Scripting Language (NX) differs from XOTcl +in the following respects:</p></div> +<div class="olist arabic"><ol class="arabic"> +<li> +<p> +<strong>Stronger Encapsulation:</strong> The Next Scripting Language favors + a <em>stronger form of encapsulation</em> than XOTcl. Calling the own + methods or accessing the own instance variables is typographically + easier and computationally faster than these operations on other + objects. This behavior is achieved via <em>resolvers</em>, which make some + methods necessary in XOTcl 1 obsolete in NX (especially for importing + instance variables). The encapsulation of NX is stronger than in + XOTcl but still weak compared to languages like C++; a developer can + still access other objects' variables via some idioms, but NX <em>makes + accesses to other objects' variables explicit</em>. The requiredness to + make these accesses explicit should encourage developer to implement + well defined interfaces to provide access to instance variables. +</p> +</li> +<li> +<p> +<strong>Additional Forms of Method Definition and Reuse:</strong> + The Next Scripting Language + provides much more orthogonal means to <em>define, reuse and + introspect</em> scripted and C-implemented methods. +</p> +<div class="olist loweralpha"><ol class="loweralpha"> +<li> +<p> +It is possible to use NX <code>alias</code> to register methods + under arbitrary names for arbitrary objects or classes. +</p> +</li> +<li> +<p> +NX provides means for <em>method protection</em> (method modifiers + <code>public</code>, <code>protected</code>, and <code>private</code>). Therefore developers have + to define explicitly public interfaces in order to use methods + from other objects. +</p> +</li> +<li> +<p> +One can invoke in NX fully qualified methods to invoke + methods outside the precedence path. +</p> +</li> +<li> +<p> +One can define in NX <em>hierarchical method names</em> (similar to + commands and subcommands, called method ensembles) in a + convenient way to provide extensible, hierarchical naming of + methods. +</p> +</li> +<li> +<p> +One can use in NX the same interface to query (introspect) + C-implemented and scripted methods/commands. +</p> +</li> +</ol></div> +</li> +<li> +<p> +<strong>Orthogonal Parameterization:</strong> + The Next Scripting Language provides an <em>orthogonal framework for + parametrization</em> of methods and objects. +</p> +<div class="olist loweralpha"><ol class="loweralpha"> +<li> +<p> +In NX, the same argument parser is used for +</p> +<div class="ulist"><ul> +<li> +<p> +Scripted Methods +</p> +</li> +<li> +<p> +C-implemented methods and Tcl commands +</p> +</li> +<li> +<p> +Object Parametrization +</p> +</li> +</ul></div> +</li> +<li> +<p> +While XOTcl 1 provided only value-checkers for non-positional + arguments for methods, the Next Scripting Framework provides + the same value checkers for positional and non-positional + arguments of methods, as well as for positional and + non-positional configure parameters (<code>-parameter</code> in + XOTcl 1). +</p> +</li> +<li> +<p> +While XOTcl 1 supported only non-positional arguments at the + begin of the argument list, these can be used now at arbitrary + positions. +</p> +</li> +</ol></div> +</li> +<li> +<p> +<strong>Value Checking:</strong> +</p> +<div class="olist loweralpha"><ol class="loweralpha"> +<li> +<p> +The Next Scripting Language supports checking of the <em>input + parameters</em> and the <em>return values</em> of scripted and C-implemented + methods and commands. +</p> +</li> +<li> +<p> +NX provides a set of predefined checkers (like e.g. <code>integer</code>, + <code>boolean</code>, <code>object</code>, …) which can be extended by the + applications. +</p> +</li> +<li> +<p> +Value Checking can be used for <em>single</em> and <em>multi-valued</em> + parameters. One can e.g. define a list of integers + with at least one entry by the parameter specification + <code>integer,1..n</code>. +</p> +</li> +<li> +<p> +Value Checking can be turned on/off globally or on the + method/command level. +</p> +</li> +</ol></div> +</li> +<li> +<p> +<strong>Scripted Init Blocks:</strong> The Next Scripting Language provides + <em>scripted init blocks</em> for objects and classes (replacement for the + dangerous dash "-" mechanism in XOTcl that allows one to set variables + and invoke methods upon object creation). +</p> +</li> +<li> +<p> +<strong>More Conventional Naming for Predefined Methods:</strong> The naming of + the methods in the Next Scripting Language is much more in line with + the mainstream naming conventions in OO languages. While for example + XOTcl uses <code>proc</code> and <code>instproc</code> for object specific and inheritable + methods, NX uses simply <code>method</code>. +</p> +</li> +<li> +<p> +<strong>Profiling Support:</strong> The Next Scripting Language provides now two + forms of profiling +</p> +<div class="ulist"><ul> +<li> +<p> +Profiling via a DTrace provider (examples are e.g. in the dtrace + subdirectory of the source tree) +</p> +</li> +<li> +<p> +Significantly improved built-in profiling (results can be + processed in Tcl). +</p> +</li> +</ul></div> +</li> +<li> +<p> +<strong>Significantly Improved Test Suite:</strong> The regression test suite of + Next Scripting Scripting framework contain now more than + 5.000 tests, and order of magnitude more than in XOTcl 1.6 +</p> +</li> +<li> +<p> +<strong>Much Smaller Interface:</strong> The Next Scripting Language has a much + <em>smaller interface</em> (i.e. provides less predefined methods) than + XOTcl (see Table 1), although the expressiveness was increased in + NX. +</p> +</li> +</ol></div> +<div class="tableblock"> +<table rules="all" +width="50%" +frame="hsides" +cellspacing="0" cellpadding="4"> +<caption class="title">Table 1. Comparison of the Number of Predefined Methods in NX and XOTcl</caption> +<col width="60%" /> +<col width="20%" /> +<col width="20%" /> +<thead> +<tr> +<th align="left" valign="top"></th> +<th align="right" valign="top">NX</th> +<th align="right" valign="top">XOTcl</th> +</tr> +</thead> +<tfoot> +<tr> +<td align="left" valign="top"><p class="table">Total</p></td> +<td align="right" valign="top"><p class="table">45</p></td> +<td align="right" valign="top"><p class="table">124</p></td> +</tr> +</tfoot> +<tbody> +<tr> +<td align="left" valign="top"><p class="table">Methods for Objects</p></td> +<td align="right" valign="top"><p class="table">14</p></td> +<td align="right" valign="top"><p class="table">51</p></td> +</tr> +<tr> +<td align="left" valign="top"><p class="table">Methods for Classes</p></td> +<td align="right" valign="top"><p class="table">9</p></td> +<td align="right" valign="top"><p class="table">24</p></td> +</tr> +<tr> +<td align="left" valign="top"><p class="table">Info-methods for Objects</p></td> +<td align="right" valign="top"><p class="table">11</p></td> +<td align="right" valign="top"><p class="table">25</p></td> +</tr> +<tr> +<td align="left" valign="top"><p class="table">Info-methods for Classes</p></td> +<td align="right" valign="top"><p class="table">11</p></td> +<td align="right" valign="top"><p class="table">24</p></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>This comparison list compares mostly XOTcl 1 with NX, some features +are also available in XOTcl 2 (2a, 2c 2d, 3, 4).</p></div> +</div> +<div class="sect2"> +<h3 id="_nx_and_xotcl_scripts">1.2. NX and XOTcl Scripts</h3> +<div class="paragraph"><p>Below is a small, introductory example showing an implementation of a +class <code>Stack</code> in NX and XOTcl. The purpose of this first example is +just a quick overview. We will go into much more detailed comparison +in the next sections.</p></div> +<div class="paragraph"><p>NX supports a block syntax, where the methods are defined during the +creation of the class. The XOTcl syntax is slightly more redundant, +since every definition of a method is a single toplevel command +starting with the class name (also NX supports the style used in +XOTcl). In NX, all methods are per default protected (XOTcl does not +support protection). In NX methods are defined in the definition of +the class via <code>:method</code> or <code>:public method</code>. In XOTcl methods are +defined via the <code>instproc</code> method.</p></div> +<div class="paragraph"><p>Another difference is the notation to refer to instance variables. In +NX, instance variable are named with a single colon in the front. In +XOTcl, instance variables are imported using <code>instvar</code>.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="top">Stack example in NX </th> +<th align="left" valign="top">Stack example in XOTcl</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="top"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Stack { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Stack of Things +</span> <span class='nx-comment'># +</span> + <span class='nx-keyword'>:variable</span> things <span class='nx-string'>""</span> + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing} { + <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0 <span class='nx-variable'>$thing</span>] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> + } + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> pop {} { + <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0] + <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 1 end] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$top</span> + } +}</pre></div></div></div></td> +<td align="left" valign="top"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># Stack of Things +</span><span class='nx-comment'># +</span> +<span class='nx-keyword'>Class</span> Stack + +Stack instproc <span class='nx-keyword'>init</span> {} { + <span class='nx-keyword'>my</span> instvar things + <span class='nx-keyword'>set</span> things <span class='nx-string'>""</span> +} + +Stack instproc push {thing} { + <span class='nx-keyword'>my</span> instvar things + <span class='nx-keyword'>set</span> things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>$things</span> 0 <span class='nx-variable'>$thing</span>] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> +} + +Stack instproc pop {} { + <span class='nx-keyword'>my</span> instvar things + <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>$things</span> 0] + <span class='nx-keyword'>set</span> things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>$things</span> 1 end] +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect2"> +<h3 id="_using_xotcl_2_0_and_the_next_scripting_language_in_a_single_interpreter">1.3. Using XOTcl 2.0 and the Next Scripting Language in a Single Interpreter</h3> +<div class="paragraph"><p>In general, the Next Scripting Framework supports multiple object +systems concurrently. Effectively, every object system has different +base classes for creating objects and classes. Therefore, these object +systems can have different interfaces and names of built-in +methods. Currently, the Next Scripting Framework is packaged with +three object systems:</p></div> +<div class="ulist"><ul> +<li> +<p> +NX +</p> +</li> +<li> +<p> +XOTcl 2.0 +</p> +</li> +<li> +<p> +TclCool +</p> +</li> +</ul></div> +<div class="paragraph"><p>XOTcl 2 is highly compatible with XOTcl 1, the language NX is +described below in more details, the language TclCool was introduced +in Tip#279 and serves primarily an example of a small OO language.</p></div> +<div class="paragraph"><p>A single Tcl interpreter can host multiple Next Scripting Object +Systems at the same time. This fact makes migration from XOTcl to NX +easier. The following example script shows to use XOTcl and NX in a +single script:</p></div> +<div class="listingblock"> +<div class="title">Using Multiple Object Systems in a single Script</div> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>namespace</span> <span class='nx-keyword'>eval</span> mypackage { + + <span class='nx-keyword'>package</span> <span class='nx-keyword'>require</span> XOTcl 2.0 + + <span class='nx-comment'># Define a class with a public method foo using XOTcl +</span> <span class='nx-keyword'>xotcl::Class</span> C1 + C1 instproc foo {} {<span class='nx-keyword'>puts</span> <span class='nx-string'>"hello world"</span>} + + <span class='nx-keyword'>package</span> <span class='nx-keyword'>require</span> nx + + <span class='nx-comment'># Define a class with a public method foo using NX +</span> <span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C2 { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>puts</span> <span class='nx-string'>"hello world"</span>} + } +}</pre></div></div> +<div class="paragraph"><p>One could certainly create object or classes from the different object +systems via fully qualified names (e.g. using e.g. <code>::xotcl::Class</code> or +<code>::nx::Class</code>), but for migration for systems without explicit +namespaces switching between the object systems eases migration. +"Switching" between XOTcl and NX effectively means the load some +packages (if needed) and to import either the base classes (Object and +Class) of XOTcl or NX into the current namespace.</p></div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_xotcl_idioms_in_the_next_scripting_language">2. XOTcl Idioms in the Next Scripting Language</h2> +<div class="sectionbody"> +<div class="paragraph"><p>The following sections are intended for reader familiar with XOTcl and +show, how certain language Idioms of XOTcl can be expressed in NX. In +some cases, multiple possible realizations are listed</p></div> +<div class="sect2"> +<h3 id="_defining_objects_and_classes">2.1. Defining Objects and Classes</h3> +<div class="paragraph"><p>When creating objects or classes, one should use the method <code>create</code> +explicitly. In XOTcl, a default <code>unknown</code> method handler was provided for +classes, which create for every unknown method invocation an +object/class with the name of the invoked method. This technique was +convenient, but as well dangerous, since typos in method names lead +easily to unexpected behavior. This default unknown method handler is not +provided in NX (but can certainly be provided as a one-liner in NX by +the application).</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> ClassName</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> ClassName</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Object</span> ObjectName</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> ObjectName</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect2"> +<h3 id="_defining_methods">2.2. Defining Methods</h3> +<div class="paragraph"><p>In general, both XOTcl and NX support methods on the object level +(per-object methods, i.e. methods only applicable to a single object) +and on the class level (methods inherited to instances of the +classes). While the naming in XOTcl tried to follow closely the Tcl +tradition (using the term <code>proc</code> for functions/methods), NX uses the +term <code>method</code> for defining scripted methods.</p></div> +<div class="paragraph"><p>XOTcl uses the prefix <code>inst</code> to denote that methods are provided for +instances, calling therefore scripted methods for instances +<code>instproc</code>. This is certainly an unusual term. The approach with the +name prefix has the disadvantage, that for every different kind of +method, two names have to be provided (e.g. <code>proc</code> and <code>instproc</code>, +<code>forward</code> and <code>instforward</code>).</p></div> +<div class="paragraph"><p>NX on the contrary uses the same term for defining instance method or +object-specific methods. When the term (e.g. <code>method</code>) is used on a +class, the method will be an instance method (i.e. applicable to the +instances of the class). When the term is used on an object with the +modifier <code>object</code>, an object-specific method is defined. This way one +can define the same way object specific methods on an object as well +as on a class.</p></div> +<div class="paragraph"><p>Furthermore, both XOTcl and NX distinguish between scripted methods +(section 3.2.1) and C-defined methods (section 3.2.2). Section 3.2.3 +introduces method protection, which is only supported by NX.</p></div> +<div class="sect3"> +<h4 id="_scripted_methods_defined_in_the_init_block_of_a_class_object_or_with_separate_calls">2.2.1. Scripted Methods Defined in the Init-block of a Class/Object or with Separate Calls</h4> +<div class="paragraph"><p>The following examples show the definition of a class and its methods +in the init-block of a class (NX only), and the definition of methods +via separate top level calls (XOTcl and NX).</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define instance method 'foo' and object +</span><span class='nx-comment'># method 'bar' for a Class 'C' with separate +</span><span class='nx-comment'># toplevel commands +</span> +<span class='nx-keyword'>Class</span> C +C instproc foo args {...} +C <span class='nx-keyword'>proc</span> bar args {...}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define instance method and object method +</span><span class='nx-comment'># in the init-block of a class +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:method</span> foo args {...} + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>method</span> bar args {...} +}</pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define instance method and object method +</span><span class='nx-comment'># with separate commands +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C +C <span class='nx-keyword'>method</span> foo args {...} +C <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar args {...}</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define object-specific method foo +</span><span class='nx-comment'># for an object 'o' with separate commands +</span> +<span class='nx-keyword'>Object</span> o +o <span class='nx-keyword'>set</span> x 1 +o <span class='nx-keyword'>proc</span> foo args {...}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define object method and set +</span><span class='nx-comment'># instance variable in the init-block of +</span><span class='nx-comment'># an object +</span> +<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { + <span class='nx-keyword'>set</span> :x 1 + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>method</span> foo args {...} +}</pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define object method and set +</span><span class='nx-comment'># instance variable with separate +</span><span class='nx-comment'># commands +</span> +<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o +o <span class='nx-keyword'>eval</span> {<span class='nx-keyword'>set</span> :x 1} +o <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo args {...}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_different_kinds_of_methods">2.2.2. Different Kinds of Methods</h4> +<div class="paragraph"><p>This section describes various kinds of methods. The different kinds +of methods are defined via different method-defining methods, which +are summarized in the following table for XOTcl and NX.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Methods for defining methods: +</span><span class='nx-comment'># +</span><span class='nx-comment'># proc +</span><span class='nx-comment'># instproc +</span><span class='nx-comment'># forward +</span><span class='nx-comment'># instforward +</span><span class='nx-comment'># parametercmd +</span><span class='nx-comment'># instparametercmd +</span><span class='nx-comment'># +</span><span class='nx-comment'># All these methods return empty.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Methods for defining methods: +</span><span class='nx-comment'># +</span><span class='nx-comment'># alias +</span><span class='nx-comment'># forward +</span><span class='nx-comment'># method +</span><span class='nx-comment'># +</span><span class='nx-comment'># All these methods return method-handles.</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>In addition to scripted methods (previous section) XOTcl supports +forwarder (called <code>forward</code> and <code>instforward</code>) and accessor functions +to variables (called <code>parametercmd</code> and <code>instparametercmd</code>). The +accessor functions are used normally internally when object-specific +parameters are defined (see Section 3.4).</p></div> +<div class="paragraph"><p>In NX forwarders are called <code>forward</code>. NX does not provide a public +available method to define variable accessors like <code>parametercmd</code> in +XOTcl, but use internally the Next Scripting Framework primitive +<code>nsf::method::setter</code> when appropriate.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> C +C instforward f1 ... +C <span class='nx-keyword'>forward</span> f2 ... + +<span class='nx-keyword'>Object</span> o +o <span class='nx-keyword'>forward</span> f3 ...</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define forwarder +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:forward</span> f1 ... + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>forward</span> f2 ... +} + +<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>forward</span> f3 ... +}</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define setter and getter methods in XOTcl. +</span><span class='nx-comment'># +</span><span class='nx-comment'># XOTcl provides methods for these. +</span> +<span class='nx-keyword'>Class</span> C +C instparametercmd p1 +C parametercmd p2 + +<span class='nx-keyword'>Object</span> o +o parametercmd p3</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define setter and getter methods in NX. +</span><span class='nx-comment'># +</span><span class='nx-comment'># NX does not provide own methods, but uses +</span><span class='nx-comment'># the low level framework commands, since +</span><span class='nx-comment'># application developer will only +</span><span class='nx-comment'># need it in rare cases. +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C +::nsf::method::setter C p1 +::nsf::method::setter C -per-object p2 + +<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o +::nsf::method::setter o p3</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>NX supports in contrary to XOTcl the method <code>alias</code> which can be used +to register arbitrary Tcl commands or methods for an object or class +under a provided method name. Aliases can be used to reuse a certain implementation in +e.g. different object systems under potentially different names. In +some respects aliases are similar to forwarders, but they do not +involve forwarding overhead.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Method "alias" not available</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define method aliases +</span><span class='nx-comment'># (to scripted or non-scripted methods) +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:alias</span> a1 ... + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>alias</span> a2 ... +} + +<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>alias</span> a3 ... +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="method-protect-example">2.2.3. Method Modifiers and Method Protection</h4> +<div class="paragraph"><p>NX supports four method modifiers <code>object</code>, <code>public</code>, <code>protected</code> and +<code>private</code>. All method modifiers can be written in front of every +method defining command. The method modifier <code>object</code> is used to denote +object-specific methods (see above). The concept of method protection +is new in NX.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Method modifiers +</span><span class='nx-comment'># +</span><span class='nx-comment'># "object", +</span><span class='nx-comment'># "public", +</span><span class='nx-comment'># "protected", and +</span><span class='nx-comment'># "private" +</span><span class='nx-comment'># +</span><span class='nx-comment'># are not available</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Method modifiers +</span><span class='nx-comment'># +</span><span class='nx-comment'># "object", +</span><span class='nx-comment'># "public", +</span><span class='nx-comment'># "protected" +</span><span class='nx-comment'># +</span><span class='nx-comment'># are applicable for all kinds of +</span><span class='nx-comment'># method defining methods: +</span><span class='nx-comment'># +</span><span class='nx-comment'># method, forward, alias +</span><span class='nx-comment'># +</span><span class='nx-comment'># The modifier "private" is available for +</span><span class='nx-comment'># +</span><span class='nx-comment'># method, forward, alias +</span><span class='nx-comment'># +</span><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + :/<span class='nx-keyword'>method</span>-definition-method/ ... + <span class='nx-keyword'>:public</span> /<span class='nx-keyword'>method</span>-definition-method/ ... + <span class='nx-keyword'>:protected</span> /<span class='nx-keyword'>method</span>-definition-method/ ... + <span class='nx-keyword'>:private</span> /<span class='nx-keyword'>method</span>-definition-method/ ... + <span class='nx-keyword'>:object</span> /<span class='nx-keyword'>method</span>-definition-method/ ... + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> /<span class='nx-keyword'>method</span>-definition-method/ ... + <span class='nx-keyword'>:protected</span> <span class='nx-keyword'>object</span> /<span class='nx-keyword'>method</span>-definition-method/ ... + <span class='nx-keyword'>:private</span> <span class='nx-keyword'>object</span> /<span class='nx-keyword'>method</span>-definition-method/ ... +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>XOTcl does not provide method protection. In NX, all methods are +defined per default as protected. This default can be changed by the +application developer in various ways. The command <code>::nx::configure +defaultMethodCallProtection true|false</code> can be used to set the default +call protection for scripted methods, forwarder and aliases. +The defaults can be overwritten also on a class level.</p></div> +<div class="paragraph"><p>NX provides means for method hiding via the method modifier +<code>private</code>. Hidden methods can be invoked only via the <code>-local</code> flag, +which means: "call the specified method defined in the same +class/object as the currently executing method".</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># XOTcl provides no means for +</span><span class='nx-comment'># method hiding</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Hiding of methods via "private" +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Base { + <span class='nx-keyword'>:private</span> <span class='nx-keyword'>method</span> baz {a b} {<span class='nx-keyword'>expr</span> {<span class='nx-variable'>$a</span> + <span class='nx-variable'>$b</span>}} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {a b} {: -local baz <span class='nx-variable'>$a</span> <span class='nx-variable'>$b</span>} +} + +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Sub -superclass Base { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bar {a b} {: -local baz <span class='nx-variable'>$a</span> <span class='nx-variable'>$b</span>} + <span class='nx-keyword'>:private</span> <span class='nx-keyword'>method</span> baz {a b} {<span class='nx-keyword'>expr</span> {<span class='nx-variable'>$a</span> * <span class='nx-variable'>$b</span>}} + + <span class='nx-keyword'>:create</span> s1 +} + +s1 foo 3 4 ;<span class='nx-comment'># returns 7 +</span>s1 bar 3 4 ;<span class='nx-comment'># returns 12 +</span>s1 baz 3 4 ;<span class='nx-comment'># unable to dispatch method 'baz'</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="method-deletion">2.2.4. Method Deletion</h4> +<div class="paragraph"><p>NX provides an explicit <code>delete</code> method for the deletion of methods.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># XOTcl provides only method deletion with +</span><span class='nx-comment'># the equivalent of Tcl's "proc foo {} {}" +</span><span class='nx-placeholder'>/cls/</span> instproc foo {} {} +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>proc</span> foo {} {}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Deletion of Methods +</span><span class='nx-comment'># +</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>method</span> <span class='nx-placeholder'>/name/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_resolvers">2.3. Resolvers</h3> +<div class="paragraph"><p>The Next Scripting Framework defines Tcl resolvers for method and +variable names to implement object specific behavior. Within the +bodies of scripted methods these resolver treat variable and function +names starting with a colon <code>:</code> specially. In short, a colon-prefixed +variable name refers to an instance variable, and a colon-prefixed +function name refers to a method. The sub-sections below provide +detailed examples.</p></div> +<div class="paragraph"><p>Note that the resolvers of the Next Scripting Framework can be used in +the XOTcl 2.* environment as well.</p></div> +<div class="sect3"> +<h4 id="_invoking_methods">2.3.1. Invoking Methods</h4> +<div class="paragraph"><p>In XOTcl, a method of the same object can be invoked via <code>my</code>, or in +general via using the name of the object in front of the method name.</p></div> +<div class="paragraph"><p>In NX, the own methods are called via the method name prefixed with a +single colon. The invocation of the methods of other objects is the +same in NX and XOTcl.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> C +C instproc foo args {...} +C instproc bar args { + <span class='nx-keyword'>my</span> foo 1 2 3 ;<span class='nx-comment'># invoke own method +</span> o baz ;<span class='nx-comment'># invoke other object's method +</span>} +<span class='nx-keyword'>Object</span> o +o <span class='nx-keyword'>proc</span> baz {} {...}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:method</span> foo args {...} + <span class='nx-keyword'>:method</span> bar args { + :foo 1 2 3 ;<span class='nx-comment'># invoke own method +</span> o baz ;<span class='nx-comment'># invoke other object's method +</span> } +} +<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> baz {} {...} +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_accessing_own_instance_variables_from_method_bodies">2.3.2. Accessing Own Instance Variables from Method Bodies</h4> +<div class="paragraph"><p>In general, the Next Scripting Language favors the access to an +objects’s own instance variables over variable accesses of other +objects. This means that in NX it is syntactically easier to access +the own instance variables. On the contrary, in XOTcl, the variable +access to own and other variables are fully symmetric.</p></div> +<div class="paragraph"><p>In XOTcl, the following approaches are used to access instance +variables:</p></div> +<div class="ulist"><ul> +<li> +<p> +Import instance variables via <code>instvar</code> and access variables via <code>$varName</code> +</p> +</li> +<li> +<p> +Set or get instance variables via <code>my set varName ?value?</code> or other + variable accessing methods registered on <code>xotcl::Object</code> such as + <code>append</code>, <code>lappend</code>, <code>incr</code>, etc. +</p> +</li> +<li> +<p> +Register same-named accessor functions and set/get values + of instance variables via <code>my varName ?value?</code> +</p> +</li> +</ul></div> +<div class="paragraph"><p>In NX, the favored approach to access instance variables is to use +the name resolvers, although it is as well possible to import +variables via <code>nx::var import</code> or to check for the existence of +instance variables via <code>nx::var exists</code>.</p></div> +<div class="paragraph"><p>The following examples summary the use cases for accessing the own and +other instance variables.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> C +C instproc foo args { + <span class='nx-comment'># Method scoped variable a +</span> <span class='nx-keyword'>set</span> a 1 + <span class='nx-comment'># Instance variable b +</span> <span class='nx-keyword'>my</span> instvar b + <span class='nx-keyword'>set</span> b 2 + <span class='nx-comment'># Global variable/namespaced variable c +</span> <span class='nx-keyword'>set</span> ::c 3 +}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:method</span> foo args {...} + <span class='nx-comment'># Method scoped variable a +</span> <span class='nx-keyword'>set</span> a 1 + <span class='nx-comment'># Instance variable b +</span> <span class='nx-keyword'>set</span> :b 2 + <span class='nx-comment'># Global variable/namespaced variable c +</span> <span class='nx-keyword'>set</span> ::c 3 + } +}</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>... instproc ... { + <span class='nx-keyword'>my</span> <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> +}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Set own instance variable to a value via +</span><span class='nx-comment'># resolver (preferred and fastest way) +</span> +... <span class='nx-keyword'>method</span> ... { + <span class='nx-keyword'>set</span> :<span class='nx-placeholder'>/newVar/</span> <span class='nx-placeholder'>?value?</span> +}</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>... instproc ... { + <span class='nx-keyword'>my</span> instvar <span class='nx-placeholder'>/varName/</span> + <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> +}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Set own instance variable via +</span><span class='nx-comment'># variable import +</span> +... <span class='nx-keyword'>method</span> ... { + ::nx::var import [<span class='nx-keyword'>self</span>] <span class='nx-placeholder'>/varName/</span> + <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> +}</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>... instproc ... { + <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> [<span class='nx-keyword'>my</span> <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/otherVar/</span>] +}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Read own instance variable +</span> +... <span class='nx-keyword'>method</span> ... { + <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> [<span class='nx-keyword'>set</span> :<span class='nx-placeholder'>/otherVar/</span>] +}</pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>... <span class='nx-keyword'>method</span> ... { + <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/newVar/</span> <span class='nx-variable'>${</span><span class='nx-variable'>:/otherVar/}</span> +}</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>... instproc ... { + <span class='nx-keyword'>my</span> exists <span class='nx-placeholder'>/varName/</span> +}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Test existence of own instance variable +</span> +... <span class='nx-keyword'>method</span> ... { + <span class='nx-keyword'>info</span> :<span class='nx-placeholder'>/varName/</span> +}</pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'> ... <span class='nx-keyword'>method</span> ... { + ::nx::var exists [<span class='nx-keyword'>self</span>] <span class='nx-placeholder'>/varName/</span> +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_accessing_instance_variables_of_other_objects">2.3.3. Accessing Instance Variables of other Objects</h4> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Set instance variable of object obj to a +</span><span class='nx-comment'># value via resolver +</span><span class='nx-comment'># (preferred way: define property on obj) +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>eval</span> [<span class='nx-keyword'>list</span> <span class='nx-keyword'>set</span> :<span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span>]</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> [<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/otherVar/</span>]</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Read instance variable of object obj +</span><span class='nx-comment'># via resolver +</span> +<span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> [<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>eval</span> {<span class='nx-keyword'>set</span> :<span class='nx-placeholder'>/otherVar/</span>}]</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>... instproc ... { + <span class='nx-placeholder'>/obj/</span> instvar <span class='nx-placeholder'>/varName/</span> + <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> +}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Read instance variable of object /obj/ +</span><span class='nx-comment'># via import +</span> +... <span class='nx-keyword'>method</span> ... { + ::nx::var import <span class='nx-placeholder'>/obj/</span> <span class='nx-placeholder'>/varName/</span> + <span class='nx-keyword'>set</span> <span class='nx-placeholder'>/varName/</span> <span class='nx-placeholder'>?value?</span> +}</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> exists varName</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Test existence of instance variable of +</span><span class='nx-comment'># object obj +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>eval</span> {<span class='nx-keyword'>info</span> exists :<span class='nx-placeholder'>/varName/</span>}</pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nx::var exists <span class='nx-placeholder'>/obj/</span> <span class='nx-placeholder'>/varName/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_parameters">2.4. Parameters</h3> +<div class="paragraph"><p>While XOTcl 1 had very limited forms of parameters, XOTcl 2 and NX +provide a generalized and highly orthogonal parameter machinery +handling various kinds of value constraints (also called value +checkers). Parameters are used to specify,</p></div> +<div class="ulist"><ul> +<li> +<p> +how objects and classes are initialized (we call these parameter types + <em>Configure Parameters</em>), and +</p> +</li> +<li> +<p> +what values can be passed to methods (we call these <em>Method + Parameters</em>). +</p> +</li> +</ul></div> +<div class="paragraph"><p>Furthermore, parameters might be positional or non-positional, they +might be optional or required, they might have a defined multiplicity, +and value-types, they might be introspected, etc. The Next Scripting +Framework provide a unified, C-implemented infrastructure to handle +both, object and method parameters in the same way with a high degree +of orthogonality.</p></div> +<div class="paragraph"><p>Configuration parameters were specified in XOTcl 1 primarily via the +method <code>parameter</code> in a rather limited way, XOTcl 1 only supported +non-positional parameters in front of positional ones, supported no +value constraints for positional parameters, provided no distinction +between optional and required, and did not support multiplicity.</p></div> +<div class="paragraph"><p>Furthermore, the Next Scripting Framework provides optionally <em>Return +Value Checking</em> based on the same mechanism to check whether some +methods return always the values as specified.</p></div> +<div class="sect3"> +<h4 id="_parameters_for_configuring_objects_variables_and_properties">2.4.1. Parameters for Configuring Objects: Variables and Properties</h4> +<div class="paragraph"><p>Configure parameters are used for specifying values for configuring +objects when they are created (i.e. how instance variables are +initialized, what parameters can be passed in for initialization, what +default values are used, etc.). Such configuration parameters are +supported in XOTcl primarily via the method <code>parameter</code>, which is used +in XOTcl to define multiple parameters via a list of parameter +specifications.</p></div> +<div class="paragraph"><p>Since the term "parameter" is underspecified, NX uses a more +differentiated terminology. NX distinguishes between configurable +instance variables (also called <em>properties</em>) and non configurable +instance variables (called <em>variables</em>), which might have as well +e.g. default values. The values of configurable properties can be +queried at runtime via <code>cget</code>, and their values can be altered via +<code>configure</code>. When the value of a configure parameter is provided or +changed, the value checkers from the variable definition are used to +ensure, the value is permissible (i.e. it is for example an integer +value). The sum of all configurable object parameters are called +<em>configure parameters</em>. To define a define a configurable variable, NX +uses the method <code>property</code>, for non-configurable variables, the method +<code>variable</code> is used.</p></div> +<div class="paragraph"><p>Optionally, one can define in NX, that a <code>property</code> or a +<code>variable</code> should have a public, protected or private accessor. Such +an accessor is a method with the same name as the variable. In XOTcl, +every <code>parameter</code> defined as well automatically a same-named accessor +method, leading to potential name conflicts with other method names.</p></div> +<div class="paragraph"><p>In the examples below we show the definition of configurable a non-configurable instance variables using <code>variable</code> and <code>property</code> +respectively.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define class "Foo" with instance +</span><span class='nx-comment'># variables "x" and "y" initialized +</span><span class='nx-comment'># on instance creation. The initialization +</span><span class='nx-comment'># has to be performed in the constructor. +</span> +<span class='nx-keyword'>Class</span> Foo +Foo instproc <span class='nx-keyword'>init</span> args { + instvar x y + <span class='nx-keyword'>set</span> x 1 + <span class='nx-keyword'>set</span> y 2 +} + +<span class='nx-comment'># Create instance of the class Foo +</span>Foo f1 + +<span class='nx-comment'># Object f1 has instance variables +</span><span class='nx-comment'># x == 1 and y == 2</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define class "Foo" with instance variables +</span><span class='nx-comment'># "x" and "y" initialized on instance creation. +</span><span class='nx-comment'># The method "variable" is similar in syntax +</span><span class='nx-comment'># to Tcl's "variable" command. During +</span><span class='nx-comment'># instance creation, the variable +</span><span class='nx-comment'># definitions are used for the +</span><span class='nx-comment'># initialization of the variables of the object. +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + <span class='nx-keyword'>:variable</span> x 1 + <span class='nx-keyword'>:variable</span> y 2 +} + +<span class='nx-comment'># Create instance of the class Foo +</span>Foo <span class='nx-keyword'>create</span> f1 + +<span class='nx-comment'># Object f1 has instance variables +</span><span class='nx-comment'># x == 1 and y == 2</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>While XOTcl follows a procedural way to initialize variables via the +constructor <code>init</code>, NX follows a more declarative approach. Often, +classes have superclasses, which often want to provide their own +instance variables and default values. The declarative approach from +NX solves this via inheritance, while a procedural approach via +assign statements in the constructor requires explicit constructor +calls, which are often error-prone. Certainly, when a user prefers to +assign initial values to instance variables via explicit assign +operations in constructors, this is as well possible in NX.</p></div> +<div class="paragraph"><p>NX uses the same mechanism to define class variables or object +variables.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># No syntactic support for creating +</span><span class='nx-comment'># class variables</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'> +<span class='nx-comment'># Define a object variable "V" with value 100 and +</span><span class='nx-comment'># an instance variable "x". "V" is defined for the +</span><span class='nx-comment'># class object Foo, "x" is defined in the +</span><span class='nx-comment'># instances of the class. "object variable" works +</span><span class='nx-comment'># similar to "object method". +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>variable</span> V 100 + <span class='nx-keyword'>:variable</span> x 1 +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>In the next step, we define configurable instance variables which we +call <em>properties</em> in NX.</p></div> +<div class="paragraph"><p>XOTcl uses the method <code>parameter</code> is a shortcut for creating multiple +configurable variables with automatically created accessors (methods for +reading and writing of the variables). In NX, the preferred way to +create configurable variables is to use the method <code>property</code>. The +method <code>property</code> in NX is similar to <code>variable</code>, but makes the +variables configurable, which means that</p></div> +<div class="olist arabic"><ol class="arabic"> +<li> +<p> +one can specify the property as a non-positional parameter upon + creation of the object, +</p> +</li> +<li> +<p> +one can query the value via the method <code>cget</code>, and +</p> +</li> +<li> +<p> +one can modify the value of the underlying variable via the method + <code>configure</code>. +</p> +</li> +</ol></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Parameters specified as a list +</span><span class='nx-comment'># (short form); parameter +</span><span class='nx-comment'># "a" has no default, "b" has default "1" +</span> +<span class='nx-keyword'>Class</span> Foo -parameter {a {b 1} {c <span class='nx-string'>"[info tclversion]"</span>}} + +<span class='nx-comment'># Create instance of the class Foo +</span>Foo f1 -a 0 + +<span class='nx-comment'># Object f1 has instance variables +</span><span class='nx-comment'># a == 0 and b == 1 +</span> +<span class='nx-comment'># XOTcl registers automatically accessors +</span><span class='nx-comment'># for the parameters. Use the accessor +</span><span class='nx-comment'># "b" to output the value of variable "b" +</span><span class='nx-keyword'>puts</span> [f1 b] + +<span class='nx-comment'># Use the setter to alter value of +</span><span class='nx-comment'># instance variable "b" +</span>f1 b 100 + +<span class='nx-comment'># Return the substituted value of +</span><span class='nx-comment'># parameter "c", something like 8.7. +</span><span class='nx-comment'># XOTcl substitutes always when it sees +</span><span class='nx-comment'># square brackets or dollar signs. +</span>f1 c +</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define property "a" and "b". The +</span><span class='nx-comment'># property "a" has no default, "b" has +</span><span class='nx-comment'># default value "1" +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + <span class='nx-keyword'>:property</span> a + <span class='nx-keyword'>:property</span> {b 1} + <span class='nx-keyword'>:property</span> {c <span class='nx-string'>"[info tclversion]"</span>} + <span class='nx-keyword'>:property</span> {d:substdefault <span class='nx-string'>"[info tclversion]"</span>} +} + +<span class='nx-comment'># Create instance of the class Foo +</span>Foo <span class='nx-keyword'>create</span> f1 -a 0 + +<span class='nx-comment'># Object f1 has instance variables +</span><span class='nx-comment'># a == 0 and b == 1 +</span> +<span class='nx-comment'># Use the method "cget" to query the value +</span><span class='nx-comment'># of a configuration parameter +</span><span class='nx-keyword'>puts</span> [f1 <span class='nx-keyword'>cget</span> -b] + +<span class='nx-comment'># Use the method "configure" to alter the +</span><span class='nx-comment'># value of instance variable "b" +</span>f1 <span class='nx-keyword'>configure</span> -b 100 + +<span class='nx-comment'># Return the (non substituted) value of +</span><span class='nx-comment'># parameter "c", and the substituted value +</span><span class='nx-comment'># of parameter "d" +</span>f1 <span class='nx-keyword'>cget</span> -c +f1 <span class='nx-keyword'>cget</span> -d +</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>In general, NX allows one to create variables and properties with and +without accessor methods. The created accessor methods might be +<code>public</code>, <code>protected</code> or <code>public</code>. When the value <code>none</code> is provided +to <code>-accessor</code>, no accessor will be created. This is actually the +default in NX. In order to change the default behavior in NX, one can use +<code>::nx::configure defaultAccessor none|public|protected|private</code>.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># "parameter" creates always accessor +</span><span class='nx-comment'># methods, accessor methods are +</span><span class='nx-comment'># always public, no "cget" is available. +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo -parameter {a {b 1}} + +<span class='nx-comment'># Use the accessor method to query +</span><span class='nx-comment'># the value of a configuration parameter +</span><span class='nx-keyword'>puts</span> [f1 b] + +<span class='nx-comment'># Use the accessor method to set the +</span><span class='nx-comment'># value of instance variable "a" +</span>f1 a 100 + +<span class='nx-comment'># Use the accessor method to unset the +</span><span class='nx-comment'># value of instance variable "a" n.a. via +</span><span class='nx-comment'># accessor</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define property "a" and "b". The +</span><span class='nx-comment'># property "a" has no default, "b" has +</span><span class='nx-comment'># default value "1" +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + <span class='nx-keyword'>:variable</span> -accessor <span class='nx-keyword'>public</span> a + <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>public</span> {b 1} +} + +<span class='nx-comment'># Use the accessor method to query +</span><span class='nx-comment'># the value of a configuration parameter +</span><span class='nx-keyword'>puts</span> [f1 b get] + +<span class='nx-comment'># Use the accessor method to set the +</span><span class='nx-comment'># value of instance variable "a" +</span>f1 a <span class='nx-keyword'>set</span> 100 + +<span class='nx-comment'># Use the accessor method to unset the +</span><span class='nx-comment'># value of instance variable "a" +</span>f1 a <span class='nx-keyword'>unset</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>Similar to <code>variable</code>, properties can be defined in NX on the class +and on the object level.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># XOTcl provides no means to define +</span><span class='nx-comment'># configurable variables at the object +</span><span class='nx-comment'># level</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define class with a property for the class object +</span><span class='nx-comment'># named "cp". This is similar to "static variables" +</span><span class='nx-comment'># in some other object-oriented programming +</span><span class='nx-comment'># languages. +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + ... + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>property</span> cp 101 +} + +<span class='nx-comment'># Define object property "op" +</span> +<span class='nx-keyword'>Object</span> <span class='nx-keyword'>create</span> o { + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>property</span> op 102 +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>NX supports <em>value constraints</em> (value-checkers) for object and method +parameters in an orthogonal manner. NX provides a predefined set of +value checkers, which can be extended by the application developer. +In NX, the <em>value checking is optional</em>. This means that it is possible to +develop e.g. which a large amount of value-checking and deploy the +script with value checking turned off, if the script is highly +performance sensitive.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># No value constraints for +</span><span class='nx-comment'># parameter available</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Predefined value constraints: +</span><span class='nx-comment'># object, class, alnum, alpha, ascii, boolean, +</span><span class='nx-comment'># control, digit, double, false, graph, integer, +</span><span class='nx-comment'># lower, parameter, print, punct, space, true, +</span><span class='nx-comment'># upper, wordchar, xdigit +</span><span class='nx-comment'># +</span><span class='nx-comment'># User defined value constraints are possible. +</span><span class='nx-comment'># All parameter value checkers can be turned on +</span><span class='nx-comment'># and off at runtime. +</span><span class='nx-comment'># +</span><span class='nx-comment'># Define a required boolean property "a" +</span><span class='nx-comment'># and an integer property "b" with a default. +</span><span class='nx-comment'># The first definition uses "properties", +</span><span class='nx-comment'># the second definition uses multiple +</span><span class='nx-comment'># "property" statements. +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo -properties { + a:boolean + {b:integer 1} +}</pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + <span class='nx-keyword'>:property</span> a:boolean + <span class='nx-keyword'>:property</span> {b:integer 1} +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>In XOTcl all configure parameters were <em>optional</em>. Required parameters have +to be passed to the constructor of the object.</p></div> +<div class="paragraph"><p>NX allows one to define <em>optional</em> and <em>required</em> configure parameters (as +well as method parameters). Therefore, configure parameters can be used +as the single mechanism to parametrize objects. It is in NX not +necessary (and per default not possible) to pass arguments to the +constructor.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Required parameter not available</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Required parameter: +</span><span class='nx-comment'># Define a required property "a" and a +</span><span class='nx-comment'># required boolean property "b" +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo -properties { + a:required + b:boolean,required +}</pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + <span class='nx-keyword'>:property</span> a:required + <span class='nx-keyword'>:property</span> b:boolean,required +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>NX supports in contrary to XOTcl to define the <em>multiplicity</em> of values +per parameter. In NX, one can specify that a parameter can accept the +value "" (empty) in addition to e.g. an integer, or one can specify that the +value is an empty or non-empty list of values via the multiplicity. For +every specified value, the value checkers are applied.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Multiplicity for parameter +</span><span class='nx-comment'># not available</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Parameter with multiplicity +</span><span class='nx-comment'># ints is a list of integers, with default +</span><span class='nx-comment'># objs is a non-empty list of objects +</span><span class='nx-comment'># obj is a single object, maybe empty +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo -properties { + {ints:integer,0..n <span class='nx-string'>""</span>} + objs<span class='nx-keyword'>:object</span>,1..n + obj<span class='nx-keyword'>:object</span>,0..1 +}</pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + <span class='nx-keyword'>:property</span> {ints:integer,0..n <span class='nx-string'>""</span>} + <span class='nx-keyword'>:property</span> objs<span class='nx-keyword'>:object</span>,1..n + <span class='nx-keyword'>:property</span> obj<span class='nx-keyword'>:object</span>,0..1 +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>For the implementation of variables and properties, NX uses slot +objects, which are an extension to the <code>-slots</code> already available in +XOTcl. While very for every <code>property</code> in NX, a slot object is created, +for performance reasons, not every <code>variable</code> has a slot associated.</p></div> +<div class="paragraph"><p>When a property is created, NX does actually three things:</p></div> +<div class="olist arabic"><ol class="arabic"> +<li> +<p> +Create a slot object, which can be specified in more detail + using the init-block of the slot object +</p> +</li> +<li> +<p> +Create a parameter definition for the initialization of the + object (usable via a non-positional parameter during object + creation), and +</p> +</li> +<li> +<p> +register optionally an accessor function (setter), for which the usual + protection levels (<code>public</code>, <code>protected</code> or <code>private</code>) can be used. +</p> +</li> +</ol></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define parameters via slots +</span> +<span class='nx-keyword'>Class</span> Foo -slots { + <span class='nx-keyword'>Attribute</span> a + <span class='nx-keyword'>Attribute</span> b -default 1 +} + +<span class='nx-comment'># Create instance of the class Foo +</span><span class='nx-comment'># and provide a value for instance +</span><span class='nx-comment'># variable "a" +</span>Foo f1 -a 0 + +<span class='nx-comment'># Object f1 has a == 0 and b == 1</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Configurable parameters specified via the +</span><span class='nx-comment'># method "property" (supports method +</span><span class='nx-comment'># modifiers and scripted configuration; +</span><span class='nx-comment'># see below) +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Foo { + <span class='nx-keyword'>:property</span> a + <span class='nx-keyword'>:property</span> {b 1} +} + +<span class='nx-comment'># Create instance of the class Foo and +</span><span class='nx-comment'># provide a value for instance variable "a" +</span>Foo <span class='nx-keyword'>create</span> f1 -a 0 + +<span class='nx-comment'># Object f1 has a == 0 and b == 1</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>Since the slots are objects, the slot objects can be configured and +parametrized like every other object in NX. Slot objects can be +provided with a scripted initialization as well. We show first the +definition of properties similar to the functionality provided as well +by XOTcl and show afterwards how to use value constraints, optional +parameters, etc. in NX.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define parameter with an +</span><span class='nx-comment'># attribute-specific type checker +</span> +<span class='nx-keyword'>Class</span> Person -slots { + <span class='nx-keyword'>Attribute</span> <span class='nx-keyword'>create</span> sex -type <span class='nx-string'>"sex"</span> { + <span class='nx-keyword'>my</span> <span class='nx-keyword'>proc</span> type=sex {name value} { + <span class='nx-keyword'>switch</span> -glob <span class='nx-variable'>$value</span> { + m* {<span class='nx-keyword'>return</span> m} + f* {<span class='nx-keyword'>return</span> f} + default { + <span class='nx-keyword'>error</span> <span class='nx-string'>"expected sex but got $value"</span> + } + } + } + } +}</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Configure parameter with scripted +</span><span class='nx-comment'># definition (init-block), defining a +</span><span class='nx-comment'># property specific type checker +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> Person { + <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>public</span> sex:sex,convert { + + <span class='nx-comment'># define a converter to standardize representation +</span> <span class='nx-keyword'>:object</span> <span class='nx-keyword'>method</span> type=sex {name value} { + <span class='nx-keyword'>switch</span> -glob <span class='nx-variable'>$value</span> { + m* {<span class='nx-keyword'>return</span> m} + f* {<span class='nx-keyword'>return</span> f} + default {<span class='nx-keyword'>error</span> <span class='nx-string'>"expected sex but got $value"</span>} + } + } + + } +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>The parameters provided by a class for the initialization of +instances can be introspected via querying the parameters +of the method create: <code>/cls/ info lookup parameters create</code> +(see <a href="#info_configure_parameter">[info_configure_parameter]</a>).</p></div> +</div> +<div class="sect3"> +<h4 id="_delete_variable_handlers">2.4.2. Delete Variable Handlers</h4> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># No syntactic support for deleting +</span><span class='nx-comment'># variable handlers</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Like deletion of Methods: +</span><span class='nx-comment'># Delete on the object, where the +</span><span class='nx-comment'># variable handler is defined. +</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>property</span> <span class='nx-placeholder'>/name/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>property</span> <span class='nx-placeholder'>/name/</span> + +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>variable</span> <span class='nx-placeholder'>/name/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>delete</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>variable</span> <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_method_parameters">2.4.3. Method Parameters</h4> +<div class="paragraph"><p>Method parameters are used to specify the interface of a single method +(what kind of values may be passed to a method, what default values +are provided etc.). The method parameters specifications in XOTcl 1 +were limited and allowed only value constraints for non positional +arguments.</p></div> +<div class="paragraph"><p>NX and XOTcl 2 provide value constraints for all kind of method parameters. +While XOTcl 1 required non-positional arguments to be listed in front of +positional arguments, this limitation is lifted in XOTcl 2.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define method foo with non-positional +</span><span class='nx-comment'># parameters (x, y and y) and positional +</span><span class='nx-comment'># parameter (a and b) +</span> +<span class='nx-keyword'>Class</span> C +C instproc foo { + -x:integer + -y:required + -z + a + b +} { + <span class='nx-comment'># ... +</span>} +C <span class='nx-keyword'>create</span> c1 + +<span class='nx-comment'># invoke method foo +</span>c1 foo -x 1 -y a 2 3</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define method foo with +</span><span class='nx-comment'># non-positional parameters +</span><span class='nx-comment'># (x, y and y) and positional +</span><span class='nx-comment'># parameter (a and b) +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo { + -x:integer + -y:required + -z + a + b + } { + <span class='nx-comment'># ... +</span> } + <span class='nx-keyword'>:create</span> c1 +} +<span class='nx-comment'># invoke method foo +</span>c1 foo -x 1 -y a 2 3</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Only leading non-positional +</span><span class='nx-comment'># parameters are available; no +</span><span class='nx-comment'># optional positional parameters, +</span><span class='nx-comment'># no value constraints on +</span><span class='nx-comment'># positional parameters, +</span><span class='nx-comment'># no multiplicity, ...</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define various forms of parameters +</span><span class='nx-comment'># not available in XOTcl 1 +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-comment'># trailing (or interleaved) non-positional +</span> <span class='nx-comment'># parameters +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> m1 {a b -x:integer -y} { + <span class='nx-comment'># ... +</span> } + + <span class='nx-comment'># positional parameters with value constraints +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> m2 {a:integer b:boolean} { + <span class='nx-comment'>#... +</span> } + + <span class='nx-comment'># optional positional parameter (trailing) +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> <span class='nx-keyword'>set</span> {varName value:optional} { + <span class='nx-comment'># .... +</span> } + + <span class='nx-comment'># parameter with multiplicity +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> m3 {-objs<span class='nx-keyword'>:object</span>,1..n c<span class='nx-keyword'>:class</span>,0..1} { + <span class='nx-comment'># ... +</span> } + + <span class='nx-comment'># In general, the same list of value +</span> <span class='nx-comment'># constraints as for configure parameter is +</span> <span class='nx-comment'># available (see above). +</span> <span class='nx-comment'># +</span> <span class='nx-comment'># User defined value constraints are +</span> <span class='nx-comment'># possible. All parameter value checkers +</span> <span class='nx-comment'># can be turned on and off. +</span>}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_return_value_checking">2.4.4. Return Value Checking</h4> +<div class="paragraph"><p><em>Return value checking</em> is a functionality available in the Next +Scripting Framework, that was not yet available in XOTcl 1. A return +value checker assures that a method returns always a value satisfying +some value constraints. Return value checkers can be defined on all +forms of methods (scripted or C-implemented). Like for other value +checkers, return value checkers can be turned on and off.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># No return value checking +</span><span class='nx-comment'># available</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define method foo with non-positional +</span><span class='nx-comment'># parameters (x, y and y) and positional +</span><span class='nx-comment'># parameter (a and b) +</span> +<span class='nx-keyword'>Class</span> <span class='nx-keyword'>create</span> C { + + <span class='nx-comment'># Define method foo which returns an +</span> <span class='nx-comment'># integer value +</span> <span class='nx-keyword'>:method</span> foo -returns integer {-x:integer} { + <span class='nx-comment'># ... +</span> } + + <span class='nx-comment'># Define an alias for the Tcl command ::incr +</span> <span class='nx-comment'># and assure, it always returns an integer +</span> <span class='nx-comment'># value +</span> <span class='nx-keyword'>:alias</span> <span class='nx-keyword'>incr</span> -returns integer ::incr + + <span class='nx-comment'># Define a forwarder that has to return an +</span> <span class='nx-comment'># integer value +</span> <span class='nx-keyword'>:forward</span> ++ -returns integer ::expr 1 + + + <span class='nx-comment'># Define a method that has to return a +</span> <span class='nx-comment'># non-empty list of objects +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> instances {} \ + -returns <span class='nx-keyword'>object</span>,1..n { + <span class='nx-keyword'>return</span> [<span class='nx-keyword'>:info</span> instances] + } +}</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_interceptors">2.5. Interceptors</h3> +<div class="paragraph"><p>XOTcl and NX allow the definition of the same set of interceptors, +namely class- and object-level mixins and class- and object-level +filters. The primary difference in NX is the naming, since NX abandons +the prefix "inst" from the names of instance specific method, but uses +the modifier <code>object</code>" for object specific methods.</p></div> +<div class="paragraph"><p>Therefore, in NX, if a <code>mixin</code> is registered on a class-level, it is +applicable for the instances (a per-class mixin), and if and <code>object +mixin</code> is registered, it is a per-object mixin. In both cases, the +term <code>mixin</code> is used, in the second case with the modifier +<code>object</code>. As in all other cases, one can register the same way a +per-object mixin on a plain object or on a class object.</p></div> +<div class="sect3"> +<h4 id="_register_mixin_classes_and_mixin_guards">2.5.1. Register Mixin Classes and Mixin Guards</h4> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> instmixin ... +<span class='nx-placeholder'>/cls/</span> instmixinguard /<span class='nx-keyword'>mixin</span>/ <span class='nx-placeholder'>?condition?</span> + +<span class='nx-comment'># Query per-class mixin +</span><span class='nx-placeholder'>/cls/</span> instmixin</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Register/clear per-class mixin and guard for +</span><span class='nx-comment'># a class +</span> +<span class='nx-placeholder'>/cls/</span> mixins add|<span class='nx-keyword'>set</span>|clear ... +<span class='nx-placeholder'>/cls/</span> mixins <span class='nx-keyword'>guard</span> /<span class='nx-keyword'>mixin</span>/ <span class='nx-placeholder'>?condition?</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>configure</span> -mixin ... + +<span class='nx-comment'># Query per-class mixins +</span><span class='nx-placeholder'>/cls/</span> mixins get +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>cget</span> -mixins + +<span class='nx-comment'># Query per-class mixins (without guards) +</span><span class='nx-placeholder'>/cls/</span> mixins classes</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>mixin</span> ... +<span class='nx-placeholder'>/obj/</span> mixinguard /<span class='nx-keyword'>mixin</span>/ <span class='nx-placeholder'>?condition?</span> + +<span class='nx-comment'># Query per-object mixins +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>mixin</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Register/clear per-object mixin and guard for +</span><span class='nx-comment'># an object +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> mixins add|<span class='nx-keyword'>set</span>|clear ... +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> mixins <span class='nx-keyword'>guard</span> /<span class='nx-keyword'>mixin</span>/ <span class='nx-placeholder'>?condition?</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>configure</span> -object-mixins ... + +<span class='nx-comment'># Query per-object mixin +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> mixins get +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>cget</span> -object-mixin + +<span class='nx-comment'># Query per-object mixins (without guards) +</span><span class='nx-placeholder'>/cls/</span> mixins classes</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_register_filters_and_filter_guards">2.5.2. Register Filters and Filter Guards</h4> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Register per-class filter and guard for +</span><span class='nx-comment'># a class +</span><span class='nx-placeholder'>/cls/</span> instfilter ... +<span class='nx-placeholder'>/cls/</span> instfilterguard /<span class='nx-keyword'>filter</span>/ <span class='nx-placeholder'>?condition?</span> + +<span class='nx-comment'># Query per-class filter +</span><span class='nx-placeholder'>/cls/</span> instfilter</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Register/clear per-class filter and guard for +</span><span class='nx-comment'># a class +</span> +<span class='nx-placeholder'>/cls/</span> filters add|<span class='nx-keyword'>set</span>|clear ... +<span class='nx-placeholder'>/cls/</span> filters <span class='nx-keyword'>guard</span> /<span class='nx-keyword'>filter</span>/ <span class='nx-placeholder'>?condition?</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>configure</span> -filters ... + +<span class='nx-comment'># Query per-class filters +</span><span class='nx-placeholder'>/cls/</span> filters get +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>cget</span> -filters + +<span class='nx-comment'># Query per-class filters (without guards) +</span><span class='nx-placeholder'>/cls/</span> filters <span class='nx-keyword'>methods</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>filter</span> ... +<span class='nx-placeholder'>/obj/</span> filterguard /<span class='nx-keyword'>filter</span>/ <span class='nx-placeholder'>?condition?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Register(clear per-object filter and guard for +</span><span class='nx-comment'># an object +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> filters add|<span class='nx-keyword'>set</span>|clear ... +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span> filters <span class='nx-keyword'>guard</span> /<span class='nx-keyword'>filter</span>/ <span class='nx-placeholder'>?condition?</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>configure</span> -object-filters ... + +<span class='nx-comment'># Query per-object filters +</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>object</span> filters get +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>cget</span> -object-filters + +<span class='nx-comment'># Query per-object filters (without guards) +</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>object</span> filters <span class='nx-keyword'>methods</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_introspection">2.6. Introspection</h3> +<div class="paragraph"><p>In general, introspection in NX became more orthogonal and less +dependent on the type of the method. In XOTcl it was e.g. necessary +that a developer had to know, whether a method is e.g. scripted or not +and has to use accordingly different sub-methods of <code>info</code>.</p></div> +<div class="paragraph"><p>In NX, one can use e.g. always <code>info method</code> with a subcommand and the +framework tries to hide the differences as far as possible. So, one +can for example obtain with <code>info method parameter</code> the parameters of +scripted and C-implemented methods the same way, one can get the +definition of all methods via <code>info method definition</code> and one can get +an manual-like interface description via <code>info method +syntax</code>. In addition, NX provides means to query the type of +a method, and NX allows one to filter by the type of the method.</p></div> +<div class="sect3"> +<h4 id="_list_sub_and_superclass_relations">2.6.1. List sub- and superclass relations</h4> +<div class="paragraph"><p>While XOTcl used singular words for introspecting sub- and superclass +relations, NX uses plural word to indicate that potentially a list of +values is returned.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>superclass</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> superclasses <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> subclass <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> subclasses -type setter <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_methods_defined_by_classes">2.6.2. List methods defined by classes</h4> +<div class="paragraph"><p>While XOTcl uses different names for obtaining different kinds of +methods defined by a class, NX uses <code>info methods</code> in an orthogonal +manner. NX allows as well to use the call protection to filter the +returned methods.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instcommands <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instparametercmd <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type setter <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instprocs <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type scripted <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type <span class='nx-keyword'>alias</span> <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type forwarder <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -type <span class='nx-keyword'>object</span> <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> -callprotection <span class='nx-keyword'>public</span>|<span class='nx-keyword'>protected</span> ...</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_methods_defined_by_objects">2.6.3. List methods defined by objects</h4> +<div class="paragraph"><p>While XOTcl uses different names for obtaining different kinds of +methods defined by an object, NX uses <code>info methods</code> in an orthogonal +manner. NX allows as well to use the call protection to filter the +returned methods.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> commands <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> parametercmd <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type setter <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> procs <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type scripted <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type <span class='nx-keyword'>alias</span> <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type forwarder <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -type <span class='nx-keyword'>object</span> <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> -callprotection <span class='nx-keyword'>public</span>|<span class='nx-keyword'>protected</span> ...</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_check_existence_of_a_method">2.6.4. Check existence of a method</h4> +<div class="paragraph"><p>NX provides multiple ways of checking, whether a method exists; one +can use <code>info method exists</code> to check, if a given method exists +(return boolean), or one can use <code>info methods ?pattern?</code>, where +<code>pattern</code> might be a single method name without wild-card +characters. The method <code>info methods ?pattern?</code> returns a list of +matching names, which might be empty. These different methods appear +appropriate depending on the context.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>/obj|cls/ <span class='nx-keyword'>info</span> \ + [inst](commands|procs|parametercmd) \ + <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> exists <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> exists <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_callable_methods">2.6.5. List callable methods</h4> +<div class="paragraph"><p>In order to obtain for an object the set of artefacts defined in the + class hierarchy, NX uses <code>info lookup</code>. One can either lookup methods + (via <code>info lookup methods</code>) or slots (via <code>info lookup slots</code>). The + plural term refers to a potential set of return values.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>methods</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> <span class='nx-keyword'>methods</span> ... <span class='nx-placeholder'>?pattern?</span> +<span class='nx-comment'># Returns list of method names</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># List only application specific methods +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> <span class='nx-keyword'>methods</span> -source application ... <span class='nx-placeholder'>?pattern?</span> +<span class='nx-comment'># Returns list of method names</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Options for 'info methods' +</span><span class='nx-comment'># +</span><span class='nx-comment'># -incontext +</span><span class='nx-comment'># -nomixins</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Options for 'info lookup methods' +</span><span class='nx-comment'># +</span><span class='nx-comment'># -source ... +</span><span class='nx-comment'># -callprotection ... +</span><span class='nx-comment'># -incontext +</span><span class='nx-comment'># -type ... +</span><span class='nx-comment'># -nomixins</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># List slot objects defined for obj +</span><span class='nx-comment'># -source might be all|application|baseclasses +</span><span class='nx-comment'># -type is the class of the slot object +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> slots <span class='nx-placeholder'>?-type ...?</span> <span class='nx-placeholder'>?-source ...?</span> <span class='nx-placeholder'>?pattern?</span> + +<span class='nx-comment'># Returns list of slot objects</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># List registered filters +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> filters -order <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span> + +<span class='nx-comment'># List registered mixins +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> mixins -heritage <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># List registered filters +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> filters <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span> + +<span class='nx-comment'># List registered mixins +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> mixins <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_object_class_where_a_specified_method_is_defined">2.6.6. List object/class where a specified method is defined</h4> +<div class="paragraph"><p><code>info lookup</code> can be used as well to determine, where exactly an + artefact is located. One can obtain this way a method handle, where +a method or filter is defined.</p></div> +<div class="paragraph"><p>The concept of a <em>method-handle</em> is new in NX. The method-handle +can be used to obtain more information about the method, such as +e.g. the definition of the method.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> procsearch <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> <span class='nx-keyword'>method</span> <span class='nx-placeholder'>/methodName/</span> +<span class='nx-comment'># Returns method-handle</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> filtersearch <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> <span class='nx-keyword'>filter</span> <span class='nx-placeholder'>/methodName/</span> +<span class='nx-comment'># Returns method-handle</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_definition_of_scripted_methods">2.6.7. List definition of scripted methods</h4> +<div class="paragraph"><p>XOTcl contains a long list of <code>info</code> subcommands for different kinds of +methods and for obtaining more detailed information about these +methods.</p></div> +<div class="paragraph"><p>In NX, this list of <code>info</code> subcommands is much shorter and more +orthogonal. For example <code>info method definition</code> can be used to obtain +with a single command the full definition of a <em>scripted method</em>, and +furthermore, it works as well the same way to obtain e.g. the +definition of a <em>forwarder</em> or an <em>alias</em>.</p></div> +<div class="paragraph"><p>While XOTcl uses different names for info options for objects and +classes (using the prefix "inst" for instance specific method), NX +uses for object specific method the modifier <code>object</code>. For definition +of class object specific methods, use the modifier <code>object</code> as usual.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> definition <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> definition <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instbody <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> body <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> body <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> body <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instargs <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> args <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> args <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> args <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instnonposargs <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> args <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> parameter <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> parameter <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instdefault <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> default <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># not needed, part of +</span><span class='nx-comment'># "info ?object? method parameter"</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instpre <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> pre <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> precondition <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> precondition <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instpost <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> post <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> postcondition <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> postcondition <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +<div class="paragraph"><p>Another powerful introspection option in NX is <code>info ?object? method +syntax</code> which obtains a representation of the parameters of a +method in the style of Tcl man pages (regardless of the kind of +method).</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> syntax <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> syntax <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="info_configure_parameter">2.6.8. List Configure Parameters</h4> +<div class="paragraph"><p>The way, how newly created objects can be configured is determined in NX +via properties. The configuration happens during creation via the +methods <code>create</code> or <code>new</code> or during runtime via <code>configure</code>. These +methods have therefore virtual argument lists, depending on the object +or class on which they are applied.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Return the parameters applicable to +</span><span class='nx-comment'># the create method of a certain class. +</span><span class='nx-comment'># class can be configured. A pattern can +</span><span class='nx-comment'># be used to filter the results. +</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> parameters <span class='nx-keyword'>create</span> ?<span class='nx-placeholder'>/pattern/</span>? + +<span class='nx-comment'># Return in the result in documentation syntax +</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>create</span> ?<span class='nx-placeholder'>/pattern/</span>? + +<span class='nx-comment'># "info lookup parameters configure" returns +</span><span class='nx-comment'># parameters available for configuring the +</span><span class='nx-comment'># current object (might contain object +</span><span class='nx-comment'># specific information) +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> parameters <span class='nx-keyword'>configure</span> <span class='nx-placeholder'>?pattern?</span> + +<span class='nx-comment'># "info lookup configure syntax" returns syntax of +</span><span class='nx-comment'># a call to configure in the Tcl parameter syntax +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>configure</span> + +<span class='nx-comment'># Obtain information from a parameter +</span><span class='nx-comment'># (as e.g. returned from "info lookup +</span><span class='nx-comment'># parameters configure"). +</span> +nsf::parameter::info name <span class='nx-placeholder'>/parameter/</span> +nsf::parameter::info syntax <span class='nx-placeholder'>/parameter/</span> +nsf::parameter::info type <span class='nx-placeholder'>/parameter/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_variable_declarations_property_and_variable">2.6.9. List Variable Declarations (property and variable)</h4> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># obtain parameter definitions defined +</span><span class='nx-comment'># for a class +</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> parameter</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># "info variables" returns handles of +</span><span class='nx-comment'># properties and variables defined by this +</span><span class='nx-comment'># class or object +</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> variables <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> variables <span class='nx-placeholder'>?pattern?</span> + +<span class='nx-comment'># "info lookup variables" returns handles +</span><span class='nx-comment'># of variables and properties applicable +</span><span class='nx-comment'># for the current object (might contain +</span><span class='nx-comment'># object specific information) +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> variables <span class='nx-placeholder'>/pattern/</span> + +<span class='nx-comment'># "info variable" lists details about a +</span><span class='nx-comment'># single property or variable. +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>variable</span> definition <span class='nx-placeholder'>/handle/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>variable</span> name <span class='nx-placeholder'>/handle/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>variable</span> parameter <span class='nx-placeholder'>/handle/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_slots">2.6.10. List Slots</h4> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Return list of slots objects defined on the +</span><span class='nx-comment'># object or class +</span><span class='nx-comment'># +</span><span class='nx-comment'># -source might be all|application|baseclasses +</span><span class='nx-comment'># -type is the class of the slot object +</span><span class='nx-comment'># -closure includes slots of superclasses +</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> slots \ + <span class='nx-placeholder'>?-type value?</span> <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?-source value?</span> <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> slots <span class='nx-placeholder'>?-type ...?</span> <span class='nx-placeholder'>?pattern?</span> + +<span class='nx-comment'># List reachable slot objects defined for obj +</span><span class='nx-comment'># -source might be all|application|baseclasses +</span><span class='nx-comment'># -type is the class of the slot object +</span><span class='nx-comment'># Returns list of slot objects. +</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> slots \ + <span class='nx-placeholder'>?-type ...?</span> <span class='nx-placeholder'>?-source ... ?</span>pattern? + +<span class='nx-comment'># Obtain definition, name or parameter from +</span><span class='nx-comment'># slot object +</span> +<span class='nx-placeholder'>/slotobj/</span> definition +<span class='nx-placeholder'>/slotobj/</span> name +<span class='nx-placeholder'>/slotobj/</span> parameter</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_filter_or_mixins">2.6.11. List Filter or Mixins</h4> +<div class="paragraph"><p>In NX all introspection options for filters are provided via +<code>info filters</code> and all introspection options for mixins are +provided via <code>info mixins</code>.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>filter</span> <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-order?</span> <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> filterguard <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> filters \ + <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instfilter \ + <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-order?</span> <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instfilterguard <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> filters \ + <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>mixin</span> <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-order ?</span>pattern? +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> mixinguard <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> mixins \ + <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instmixin \ + <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-order?</span> <span class='nx-placeholder'>?pattern?</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instmixinguard <span class='nx-placeholder'>/name/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixins \ + <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?-guards?</span> <span class='nx-placeholder'>?-heritage?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_definition_of_methods_defined_by_aliases_setters_or_forwarders">2.6.12. List definition of methods defined by aliases, setters or forwarders</h4> +<div class="paragraph"><p>As mentioned earlier, <code>info method definition</code> can be used on every +kind of method. The same call can be used to obtain the definition of +a scripted method, a method-alias, a forwarder or a setter method.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> definition <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> definition <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_method_handles">2.6.13. List Method-Handles</h4> +<div class="paragraph"><p>NX supports <em>method-handles</em> to provide means to obtain further +information about a method or to change maybe some properties of a +method. When a method is created, the method creating method returns +the method handle to the created method.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># List the method handle of the specified method, +</span><span class='nx-comment'># can be used e.g. for aliases. "handle" is the short +</span><span class='nx-comment'># form of "definitionhandle". +</span><span class='nx-comment'># +</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> handle <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> handle <span class='nx-placeholder'>/methodName/</span> +<span class='nx-comment'># +</span><span class='nx-comment'># For ensemble methods (method name contains +</span><span class='nx-comment'># spaces) one can query as well the registration +</span><span class='nx-comment'># handle, which is the handle to the root of the +</span><span class='nx-comment'># ensemble; the definition handle points to the +</span><span class='nx-comment'># leaf of the ensemble. +</span><span class='nx-comment'># +</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> registrationhandle <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> registrationhandle <span class='nx-placeholder'>/methodName/</span> +<span class='nx-comment'># +</span><span class='nx-comment'># For aliases, one can query the original +</span><span class='nx-comment'># definition via "info method origin" +</span><span class='nx-comment'># +</span><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> origin <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> origin <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_type_of_a_method">2.6.14. List type of a method</h4> +<div class="paragraph"><p>The method <code>info ?object? method type</code> is new in NX to obtain the type of the +specified method.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>method</span> type <span class='nx-placeholder'>/methodName/</span> +<span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> type <span class='nx-placeholder'>/methodName/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_list_the_scope_of_mixin_classes">2.6.15. List the scope of mixin classes</h4> +<div class="paragraph"><p>NX provides a richer set of introspection options to obtain +information, where mixins classes are mixed into.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># List objects, where /cls/ is a +</span><span class='nx-comment'># per-object mixin +</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof -scope <span class='nx-keyword'>object</span> <span class='nx-placeholder'>?-closure?</span> \ + <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instmixinof <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># List classes, where /cls/ is a per-class mixin +</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof -scope <span class='nx-keyword'>class</span> <span class='nx-placeholder'>?-closure?</span> \ + <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># List objects and classes, where /cls/ is +</span><span class='nx-comment'># either a per-object or a per-class mixin +</span> +<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof -scope all <span class='nx-placeholder'>?-closure?</span> \ + <span class='nx-placeholder'>?pattern?</span></pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> mixinof <span class='nx-placeholder'>?-closure?</span> <span class='nx-placeholder'>?pattern?</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_check_properties_of_object_and_classes">2.6.16. Check properties of object and classes</h4> +<div class="paragraph"><p>Similar as noted before, NX uses rather a hierarchical approach of +naming using multiple layers of subcommands).</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> istype <span class='nx-placeholder'>/sometype/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Check if object is a subtype of some class +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> has type <span class='nx-placeholder'>/sometype/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> ismixin <span class='nx-placeholder'>/cls/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Check if object has the specified mixin registered +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> has <span class='nx-keyword'>mixin</span> <span class='nx-placeholder'>/cls/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> isclass ?<span class='nx-placeholder'>/cls/</span>?</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Check if object is an NX class +</span><span class='nx-placeholder'>/obj/</span> has type ::nx::Class + +<span class='nx-comment'># Check if object is a class in one of the +</span><span class='nx-comment'># NSF object systems +</span>::nsf::is <span class='nx-keyword'>class</span> <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> ismetaclass <span class='nx-placeholder'>/cls/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Check if class is an NX metaclass +</span><span class='nx-keyword'>expr</span> {[<span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> heritage ::nx::Class] ne <span class='nx-string'>""</span>} + +<span class='nx-comment'># Check if object is a metaclass in one of the +</span><span class='nx-comment'># NSF object systems +</span>::nsf::is <span class='nx-keyword'>metaclass</span> <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Check if object is a baseclass of an object system +</span>::nsf::is baseclass <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Return name of object (without namespace prefix) +</span><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> name</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span>::exists <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Check for existence of object (nsf primitive) +</span>::nsf::object::exists <span class='nx-placeholder'>/obj/</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect3"> +<h4 id="_call_stack_introspection">2.6.17. Call-stack Introspection</h4> +<div class="paragraph"><p>Call-stack introspection is very similar in NX and XOTcl. NX uses for +subcommand the term <code>current</code> instead of <code>self</code>, since <code>self</code> has a +strong connotation to the current object. The term <code>proc</code> is renamed +by <code>method</code>.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span></pre></div></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> <span class='nx-keyword'>object</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> <span class='nx-keyword'>class</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> <span class='nx-keyword'>class</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> args</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> args</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> <span class='nx-keyword'>proc</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> <span class='nx-keyword'>method</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> callingclass</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> calledclass</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> callingobject</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> callingobject</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> callingproc</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> callingmethod</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> calledclass</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> calledclass</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> calledproc</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> calledmethod</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> isnextcall</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> isnextcall</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> <span class='nx-keyword'>next</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Returns method-handle of the +</span><span class='nx-comment'># method to be called via "next" +</span><span class='nx-keyword'>current</span> <span class='nx-keyword'>next</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> filterreg</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Returns method-handle of the +</span><span class='nx-comment'># filter method +</span><span class='nx-keyword'>current</span> filterreg</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> callinglevel</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> callinglevel</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>self</span> activelevel</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>current</span> activelevel</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_other_predefined_methods">2.7. Other Predefined Methods</h3> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> requireNamespace</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>require</span> <span class='nx-keyword'>namespace</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># n.a.</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>require</span> <span class='nx-keyword'>method</span></pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect2"> +<h3 id="_dispatch_aliases_etc">2.8. Dispatch, Aliases, etc.</h3> +<div class="paragraph"><p>todo: to be done or omitted</p></div> +</div> +<div class="sect2"> +<h3 id="_assertions">2.9. Assertions</h3> +<div class="paragraph"><p>In contrary to XOTcl, NX provides no pre-registered methods for +assertion handling. All assertion handling can e performed via the +Next Scripting primitive <code>nsf::method::assertion</code>.</p></div> +<div class="tableblock"> +<table rules="all" +width="100%" +frame="void" +cellspacing="0" cellpadding="4"> +<col width="50%" /> +<col width="50%" /> +<thead> +<tr> +<th align="left" valign="middle">XOTcl </th> +<th align="left" valign="middle">Next Scripting Language</th> +</tr> +</thead> +<tbody> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> check <span class='nx-placeholder'>/checkoptions/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/obj/</span> check <span class='nx-placeholder'>/checkoptions/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> check</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/obj/</span> check</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span>-invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>info</span> invar</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/obj/</span> <span class='nx-keyword'>object</span>-invar</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> instinvar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>class</span>-invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> instinvar</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>class</span>-invar</pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>object</span>-invar <span class='nx-placeholder'>/conditions/</span></pre></div></div></div></td> +</tr> +<tr> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>info</span> invar</pre></div></div></div></td> +<td align="left" valign="middle"><div><div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nsf::method::assertion <span class='nx-placeholder'>/cls/</span> <span class='nx-keyword'>object</span>-invar</pre></div></div></div></td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="sect2"> +<h3 id="_method_protection">2.10. Method Protection</h3> +<div class="paragraph"><p>As described <a href="#method-protect-example">above</a>, NX supports method +protection via the method modifiers <code>protected</code> and <code>public</code>. A +protected method can be only called from an object of that class, +while public methods can be called from every object. The method +protection can be used to every kind of method, such as e.g. scripted +methods, aliases, forwarders, or accessors. For invocations, +the most specific definition (might be a mixin) is used for +determining the protection.</p></div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_incompatibilities_between_xotcl_1_and_xotcl_2">3. Incompatibilities between XOTcl 1 and XOTcl 2</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_resolvers_2">3.1. Resolvers</h3> +<div class="paragraph"><p>The resolvers (variable resolvers, function resolvers) of the Next +Scripting Framework are used as well within XOTcl 2. When variable +names or method names starting with a single colon are used in XOTcl 1 +scripts, conflicts will arise with the resolver. These names must be +replaced.</p></div> +</div> +<div class="sect2"> +<h3 id="_parameters_2">3.2. Parameters</h3> +<div class="paragraph"><p>The following changes for parameters could be regarded as bug-fixes.</p></div> +<div class="sect3"> +<h4 id="_parameter_usage_without_a_value">3.2.1. Parameter usage without a value</h4> +<div class="paragraph"><p>In XOTcl 1, it was possible to call a parameter method during object +creation via the dash-interface without a value (in the example below <code>-x</code>).</p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># XOTcl example +</span> +<span class='nx-keyword'>Class</span> Foo -parameter {x y} +Foo f1 -x -y 1</pre></div></div> +<div class="paragraph"><p>Such cases are most likely mistakes. All parameter configurations in XOTcl 2 require an argument.</p></div> +</div> +<div class="sect3"> +<h4 id="_ignored_parameter_definitions">3.2.2. Ignored Parameter definitions</h4> +<div class="paragraph"><p>In XOTcl 1, a more specific parameter definition without a default was ignored +when a more general parameter definition with a default was +present. In the example below, the object <code>b1</code> contained in XOTcl 1 +incorrectly the parameter <code>x</code> (set via default from <code>Foo</code>), while in +XOTcl 2, the variable won’t be set.</p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># XOTcl example +</span> +<span class='nx-keyword'>Class</span> Foo -parameter {{x 1}} +<span class='nx-keyword'>Class</span> Bar -superclass Foo -parameter x +Bar b1</pre></div></div> +</div> +<div class="sect3"> +<h4 id="_changing_classes_and_superclasses">3.2.3. Changing classes and superclasses</h4> +<div class="paragraph"><p>NX does not define the methods <code>class</code> and <code>superclass</code> (like XOTcl), but allows one to +alter all object/class relations (including +class/superclass/object-mixin/…) +<code>nsf::relation::set</code>. The class and superclass can be certainly queried +in all variants with <code>info class</code> or <code>info superclasses</code>.</p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># NX example +</span> +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Foo +Foo <span class='nx-keyword'>create</span> f1 + +<span class='nx-comment'># now alter the class of object f1 +</span>nsf::relation::set f1 <span class='nx-keyword'>class</span> ::nx::Object</pre></div></div> +</div> +<div class="sect3"> +<h4 id="_overwriting_procs_methods_with_objects_and_vice_versa">3.2.4. Overwriting procs/methods with objects and vice versa</h4> +<div class="paragraph"><p>NSF is now more conservative on object/method creation. In contrary to +XOTcl 1 NSF does not allow one to redefined a pre-existing command +(e.g. "set") with an object and vice versa. Like in XOTcl 1, +preexisting objects and classes con be redefined (necessary for +reloading objects/classes in a running interpreter).</p></div> +</div> +<div class="sect3"> +<h4 id="_info_heritage">3.2.5. Info heritage</h4> +<div class="paragraph"><p><code>info heritage</code> returns in XOTcl 1 the transitive superclass +hierarchy, which is equivalent with <code>info superclasses -closure</code> and +therefore not necessary. In XOTcl 2 (and NX), <code>info heritage</code> includes +as well the transitive per-class mixins.</p></div> +</div> +</div> +<div class="sect2"> +<h3 id="_slots">3.3. Slots</h3> +<div class="paragraph"><p>All slot objects (also XOTcl slot objects) are now next-scripting +objects of baseclass <code>::nx::Slot</code>. The name of the experimental +default-setter <code>initcmd</code> was changed to <code>defaultcmd</code>. Code directly +working on the slots objects has to be adapted.</p></div> +</div> +<div class="sect2"> +<h3 id="_obsolete_commands">3.4. Obsolete Commands</h3> +<div class="paragraph"><p>Parameter-classes were rarely used and have been replaced by the more +general object parametrization. Therefore, <code>cl info parameterclass</code> has +been removed.</p></div> +</div> +<div class="sect2"> +<h3 id="_stronger_checking">3.5. Stronger Checking</h3> +<div class="paragraph"><p>The Next Scripting Framework performs stronger checking than XOTcl 1 +For example, the requiredness of slots in XOTcl 1 was just a +comment, while XOTcl 2 enforces it.</p></div> +</div> +<div class="sect2"> +<h3 id="_exit_handlers">3.6. Exit Handlers</h3> +<div class="paragraph"><p>The exit handler interface changed from a method of <code>::xotcl::Object</code> +into the Tcl command <code>::nsf::exithandler</code>:</p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># NX example +</span>::nsf::exithandler <span class='nx-keyword'>set</span>|get|<span class='nx-keyword'>unset</span> <span class='nx-placeholder'>?arg?</span></pre></div></div> +</div> +</div> +</div> +</div> +<div id="footnotes"><hr /></div> +<div id="footer"> +<div id="footer-text"> +Version 2.2.0<br /> +Last updated 2019-04-19 00:25:17 CEST +</div> +</div> +</body> +</html> Index: doc/next-tutorial/next-tutorial.html =================================================================== diff -u -r6cbeef2d45ae090cf57de7703e0b480125e277b1 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- doc/next-tutorial/next-tutorial.html (.../next-tutorial.html) (revision 6cbeef2d45ae090cf57de7703e0b480125e277b1) +++ doc/next-tutorial/next-tutorial.html (.../next-tutorial.html) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -1,3472 +1,3472 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" - "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> -<head> -<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> -<meta name="generator" content="AsciiDoc 8.6.9" /> -<title>Tutorial for the Next Scripting Language</title> -<style type="text/css"> -/* Shared CSS for AsciiDoc xhtml11 and html5 backends */ - -/* Default font. */ -body { - font-family: Georgia,serif; -} - -/* Title font. */ -h1, h2, h3, h4, h5, h6, -div.title, caption.title, -thead, p.table.header, -#toctitle, -#author, #revnumber, #revdate, #revremark, -#footer { - font-family: Arial,Helvetica,sans-serif; -} - -body { - margin: 1em 5% 1em 5%; -} - -a { - color: blue; - text-decoration: underline; -} -a:visited { - color: fuchsia; -} - -em { - font-style: italic; - color: navy; -} - -strong { - font-weight: bold; - color: #083194; -} - -h1, h2, h3, h4, h5, h6 { - color: #527bbd; - margin-top: 1.2em; - margin-bottom: 0.5em; - line-height: 1.3; -} - -h1, h2, h3 { - border-bottom: 2px solid silver; -} -h2 { - padding-top: 0.5em; -} -h3 { - float: left; -} -h3 + * { - clear: left; -} -h5 { - font-size: 1.0em; -} - -div.sectionbody { - margin-left: 0; -} - -hr { - border: 1px solid silver; -} - -p { - margin-top: 0.5em; - margin-bottom: 0.5em; -} - -ul, ol, li > p { - margin-top: 0; -} -ul > li { color: #aaa; } -ul > li > * { color: black; } - -.monospaced, code, pre { - font-family: "Courier New", Courier, monospace; - font-size: inherit; - color: navy; - padding: 0; - margin: 0; -} -pre { - white-space: pre-wrap; -} - -#author { - color: #527bbd; - font-weight: bold; - font-size: 1.1em; -} -#email { -} -#revnumber, #revdate, #revremark { -} - -#footer { - font-size: small; - border-top: 2px solid silver; - padding-top: 0.5em; - margin-top: 4.0em; -} -#footer-text { - float: left; - padding-bottom: 0.5em; -} -#footer-badges { - float: right; - padding-bottom: 0.5em; -} - -#preamble { - margin-top: 1.5em; - margin-bottom: 1.5em; -} -div.imageblock, div.exampleblock, div.verseblock, -div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, -div.admonitionblock { - margin-top: 1.0em; - margin-bottom: 1.5em; -} -div.admonitionblock { - margin-top: 2.0em; - margin-bottom: 2.0em; - margin-right: 10%; - color: #606060; -} - -div.content { /* Block element content. */ - padding: 0; -} - -/* Block element titles. */ -div.title, caption.title { - color: #527bbd; - font-weight: bold; - text-align: left; - margin-top: 1.0em; - margin-bottom: 0.5em; -} -div.title + * { - margin-top: 0; -} - -td div.title:first-child { - margin-top: 0.0em; -} -div.content div.title:first-child { - margin-top: 0.0em; -} -div.content + div.title { - margin-top: 0.0em; -} - -div.sidebarblock > div.content { - background: #ffffee; - border: 1px solid #dddddd; - border-left: 4px solid #f0f0f0; - padding: 0.5em; -} - -div.listingblock > div.content { - border: 1px solid #dddddd; - border-left: 5px solid #f0f0f0; - background: #f8f8f8; - padding: 0.5em; -} - -div.quoteblock, div.verseblock { - padding-left: 1.0em; - margin-left: 1.0em; - margin-right: 10%; - border-left: 5px solid #f0f0f0; - color: #888; -} - -div.quoteblock > div.attribution { - padding-top: 0.5em; - text-align: right; -} - -div.verseblock > pre.content { - font-family: inherit; - font-size: inherit; -} -div.verseblock > div.attribution { - padding-top: 0.75em; - text-align: left; -} -/* DEPRECATED: Pre version 8.2.7 verse style literal block. */ -div.verseblock + div.attribution { - text-align: left; -} - -div.admonitionblock .icon { - vertical-align: top; - font-size: 1.1em; - font-weight: bold; - text-decoration: underline; - color: #527bbd; - padding-right: 0.5em; -} -div.admonitionblock td.content { - padding-left: 0.5em; - border-left: 3px solid #dddddd; -} - -div.exampleblock > div.content { - border-left: 3px solid #dddddd; - padding-left: 0.5em; -} - -div.imageblock div.content { padding-left: 0; } -span.image img { border-style: none; vertical-align: text-bottom; } -a.image:visited { color: white; } - -dl { - margin-top: 0.8em; - margin-bottom: 0.8em; -} -dt { - margin-top: 0.5em; - margin-bottom: 0; - font-style: normal; - color: navy; -} -dd > *:first-child { - margin-top: 0.1em; -} - -ul, ol { - list-style-position: outside; -} -ol.arabic { - list-style-type: decimal; -} -ol.loweralpha { - list-style-type: lower-alpha; -} -ol.upperalpha { - list-style-type: upper-alpha; -} -ol.lowerroman { - list-style-type: lower-roman; -} -ol.upperroman { - list-style-type: upper-roman; -} - -div.compact ul, div.compact ol, -div.compact p, div.compact p, -div.compact div, div.compact div { - margin-top: 0.1em; - margin-bottom: 0.1em; -} - -tfoot { - font-weight: bold; -} -td > div.verse { - white-space: pre; -} - -div.hdlist { - margin-top: 0.8em; - margin-bottom: 0.8em; -} -div.hdlist tr { - padding-bottom: 15px; -} -dt.hdlist1.strong, td.hdlist1.strong { - font-weight: bold; -} -td.hdlist1 { - vertical-align: top; - font-style: normal; - padding-right: 0.8em; - color: navy; -} -td.hdlist2 { - vertical-align: top; -} -div.hdlist.compact tr { - margin: 0; - padding-bottom: 0; -} - -.comment { - background: yellow; -} - -.footnote, .footnoteref { - font-size: 0.8em; -} - -span.footnote, span.footnoteref { - vertical-align: super; -} - -#footnotes { - margin: 20px 0 20px 0; - padding: 7px 0 0 0; -} - -#footnotes div.footnote { - margin: 0 0 5px 0; -} - -#footnotes hr { - border: none; - border-top: 1px solid silver; - height: 1px; - text-align: left; - margin-left: 0; - width: 20%; - min-width: 100px; -} - -div.colist td { - padding-right: 0.5em; - padding-bottom: 0.3em; - vertical-align: top; -} -div.colist td img { - margin-top: 0.3em; -} - -@media print { - #footer-badges { display: none; } -} - -#toc { - margin-bottom: 2.5em; -} - -#toctitle { - color: #527bbd; - font-size: 1.1em; - font-weight: bold; - margin-top: 1.0em; - margin-bottom: 0.1em; -} - -div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { - margin-top: 0; - margin-bottom: 0; -} -div.toclevel2 { - margin-left: 2em; - font-size: 0.9em; -} -div.toclevel3 { - margin-left: 4em; - font-size: 0.9em; -} -div.toclevel4 { - margin-left: 6em; - font-size: 0.9em; -} - -span.aqua { color: aqua; } -span.black { color: black; } -span.blue { color: blue; } -span.fuchsia { color: fuchsia; } -span.gray { color: gray; } -span.green { color: green; } -span.lime { color: lime; } -span.maroon { color: maroon; } -span.navy { color: navy; } -span.olive { color: olive; } -span.purple { color: purple; } -span.red { color: red; } -span.silver { color: silver; } -span.teal { color: teal; } -span.white { color: white; } -span.yellow { color: yellow; } - -span.aqua-background { background: aqua; } -span.black-background { background: black; } -span.blue-background { background: blue; } -span.fuchsia-background { background: fuchsia; } -span.gray-background { background: gray; } -span.green-background { background: green; } -span.lime-background { background: lime; } -span.maroon-background { background: maroon; } -span.navy-background { background: navy; } -span.olive-background { background: olive; } -span.purple-background { background: purple; } -span.red-background { background: red; } -span.silver-background { background: silver; } -span.teal-background { background: teal; } -span.white-background { background: white; } -span.yellow-background { background: yellow; } - -span.big { font-size: 2em; } -span.small { font-size: 0.6em; } - -span.underline { text-decoration: underline; } -span.overline { text-decoration: overline; } -span.line-through { text-decoration: line-through; } - -div.unbreakable { page-break-inside: avoid; } - - -/* - * xhtml11 specific - * - * */ - -div.tableblock { - margin-top: 1.0em; - margin-bottom: 1.5em; -} -div.tableblock > table { - border: 3px solid #527bbd; -} -thead, p.table.header { - font-weight: bold; - color: #527bbd; -} -p.table { - margin-top: 0; -} -/* Because the table frame attribute is overriden by CSS in most browsers. */ -div.tableblock > table[frame="void"] { - border-style: none; -} -div.tableblock > table[frame="hsides"] { - border-left-style: none; - border-right-style: none; -} -div.tableblock > table[frame="vsides"] { - border-top-style: none; - border-bottom-style: none; -} - - -/* - * html5 specific - * - * */ - -table.tableblock { - margin-top: 1.0em; - margin-bottom: 1.5em; -} -thead, p.tableblock.header { - font-weight: bold; - color: #527bbd; -} -p.tableblock { - margin-top: 0; -} -table.tableblock { - border-width: 3px; - border-spacing: 0px; - border-style: solid; - border-color: #527bbd; - border-collapse: collapse; -} -th.tableblock, td.tableblock { - border-width: 1px; - padding: 4px; - border-style: solid; - border-color: #527bbd; -} - -table.tableblock.frame-topbot { - border-left-style: hidden; - border-right-style: hidden; -} -table.tableblock.frame-sides { - border-top-style: hidden; - border-bottom-style: hidden; -} -table.tableblock.frame-none { - border-style: hidden; -} - -th.tableblock.halign-left, td.tableblock.halign-left { - text-align: left; -} -th.tableblock.halign-center, td.tableblock.halign-center { - text-align: center; -} -th.tableblock.halign-right, td.tableblock.halign-right { - text-align: right; -} - -th.tableblock.valign-top, td.tableblock.valign-top { - vertical-align: top; -} -th.tableblock.valign-middle, td.tableblock.valign-middle { - vertical-align: middle; -} -th.tableblock.valign-bottom, td.tableblock.valign-bottom { - vertical-align: bottom; -} - - -/* - * manpage specific - * - * */ - -body.manpage h1 { - padding-top: 0.5em; - padding-bottom: 0.5em; - border-top: 2px solid silver; - border-bottom: 2px solid silver; -} -body.manpage h2 { - border-style: none; -} -body.manpage div.sectionbody { - margin-left: 3em; -} - -@media print { - body.manpage div#toc { display: none; } -} - - -</style> -<script type="text/javascript"> -/*<+'])'); - // Function that scans the DOM tree for header elements (the DOM2 - // nodeIterator API would be a better technique but not supported by all - // browsers). - var iterate = function (el) { - for (var i = el.firstChild; i != null; i = i.nextSibling) { - if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { - var mo = re.exec(i.tagName); - if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { - result[result.length] = new TocEntry(i, getText(i), mo[1]-1); - } - iterate(i); - } - } - } - iterate(el); - return result; - } - - var toc = document.getElementById("toc"); - if (!toc) { - return; - } - - // Delete existing TOC entries in case we're reloading the TOC. - var tocEntriesToRemove = []; - var i; - for (i = 0; i < toc.childNodes.length; i++) { - var entry = toc.childNodes[i]; - if (entry.nodeName.toLowerCase() == 'div' - && entry.getAttribute("class") - && entry.getAttribute("class").match(/^toclevel/)) - tocEntriesToRemove.push(entry); - } - for (i = 0; i < tocEntriesToRemove.length; i++) { - toc.removeChild(tocEntriesToRemove[i]); - } - - // Rebuild TOC entries. - var entries = tocEntries(document.getElementById("content"), toclevels); - for (var i = 0; i < entries.length; ++i) { - var entry = entries[i]; - if (entry.element.id == "") - entry.element.id = "_toc_" + i; - var a = document.createElement("a"); - a.href = "#" + entry.element.id; - a.appendChild(document.createTextNode(entry.text)); - var div = document.createElement("div"); - div.appendChild(a); - div.className = "toclevel" + entry.toclevel; - toc.appendChild(div); - } - if (entries.length == 0) - toc.parentNode.removeChild(toc); -}, - - -///////////////////////////////////////////////////////////////////// -// Footnotes generator -///////////////////////////////////////////////////////////////////// - -/* Based on footnote generation code from: - * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html - */ - -footnotes: function () { - // Delete existing footnote entries in case we're reloading the footnodes. - var i; - var noteholder = document.getElementById("footnotes"); - if (!noteholder) { - return; - } - var entriesToRemove = []; - for (i = 0; i < noteholder.childNodes.length; i++) { - var entry = noteholder.childNodes[i]; - if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") - entriesToRemove.push(entry); - } - for (i = 0; i < entriesToRemove.length; i++) { - noteholder.removeChild(entriesToRemove[i]); - } - - // Rebuild footnote entries. - var cont = document.getElementById("content"); - var spans = cont.getElementsByTagName("span"); - var refs = {}; - var n = 0; - for (i=0; i<spans.length; i++) { - if (spans[i].className == "footnote") { - n++; - var note = spans[i].getAttribute("data-note"); - if (!note) { - // Use [\s\S] in place of . so multi-line matches work. - // Because JavaScript has no s (dotall) regex flag. - note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1]; - spans[i].innerHTML = - "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n + - "' title='View footnote' class='footnote'>" + n + "</a>]"; - spans[i].setAttribute("data-note", note); - } - noteholder.innerHTML += - "<div class='footnote' id='_footnote_" + n + "'>" + - "<a href='#_footnoteref_" + n + "' title='Return to text'>" + - n + "</a>. " + note + "</div>"; - var id =spans[i].getAttribute("id"); - if (id != null) refs["#"+id] = n; - } - } - if (n == 0) - noteholder.parentNode.removeChild(noteholder); - else { - // Process footnoterefs. - for (i=0; i<spans.length; i++) { - if (spans[i].className == "footnoteref") { - var href = spans[i].getElementsByTagName("a")[0].getAttribute("href"); - href = href.match(/#.*/)[0]; // Because IE return full URL. - n = refs[href]; - spans[i].innerHTML = - "[<a href='#_footnote_" + n + - "' title='View footnote' class='footnote'>" + n + "</a>]"; - } - } - } -}, - -install: function(toclevels) { - var timerId; - - function reinstall() { - asciidoc.footnotes(); - if (toclevels) { - asciidoc.toc(toclevels); - } - } - - function reinstallAndRemoveTimer() { - clearInterval(timerId); - reinstall(); - } - - timerId = setInterval(reinstall, 500); - if (document.addEventListener) - document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); - else - window.onload = reinstallAndRemoveTimer; -} - -} -asciidoc.install(4); -/*]]>*/ -</script> -</head> -<body class="article"> -<div id="header"> -<h1>Tutorial for the Next Scripting Language</h1> -<span id="author">Gustaf Neumann <neumann@wu-wien.ac.at>, Stefan Sobernig <stefan.sobernig@wu.ac.at></span><br /> -<span id="revnumber">version 2.2.0,</span> -<span id="revdate">September 2018</span> -<br /><span id="revremark">Written for the Initial Release of the Next Scripting Framework.</span> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> +<head> +<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> +<meta name="generator" content="AsciiDoc 8.6.9" /> +<title>Tutorial for the Next Scripting Language</title> +<style type="text/css"> +/* Shared CSS for AsciiDoc xhtml11 and html5 backends */ + +/* Default font. */ +body { + font-family: Georgia,serif; +} + +/* Title font. */ +h1, h2, h3, h4, h5, h6, +div.title, caption.title, +thead, p.table.header, +#toctitle, +#author, #revnumber, #revdate, #revremark, +#footer { + font-family: Arial,Helvetica,sans-serif; +} + +body { + margin: 1em 5% 1em 5%; +} + +a { + color: blue; + text-decoration: underline; +} +a:visited { + color: fuchsia; +} + +em { + font-style: italic; + color: navy; +} + +strong { + font-weight: bold; + color: #083194; +} + +h1, h2, h3, h4, h5, h6 { + color: #527bbd; + margin-top: 1.2em; + margin-bottom: 0.5em; + line-height: 1.3; +} + +h1, h2, h3 { + border-bottom: 2px solid silver; +} +h2 { + padding-top: 0.5em; +} +h3 { + float: left; +} +h3 + * { + clear: left; +} +h5 { + font-size: 1.0em; +} + +div.sectionbody { + margin-left: 0; +} + +hr { + border: 1px solid silver; +} + +p { + margin-top: 0.5em; + margin-bottom: 0.5em; +} + +ul, ol, li > p { + margin-top: 0; +} +ul > li { color: #aaa; } +ul > li > * { color: black; } + +.monospaced, code, pre { + font-family: "Courier New", Courier, monospace; + font-size: inherit; + color: navy; + padding: 0; + margin: 0; +} +pre { + white-space: pre-wrap; +} + +#author { + color: #527bbd; + font-weight: bold; + font-size: 1.1em; +} +#email { +} +#revnumber, #revdate, #revremark { +} + +#footer { + font-size: small; + border-top: 2px solid silver; + padding-top: 0.5em; + margin-top: 4.0em; +} +#footer-text { + float: left; + padding-bottom: 0.5em; +} +#footer-badges { + float: right; + padding-bottom: 0.5em; +} + +#preamble { + margin-top: 1.5em; + margin-bottom: 1.5em; +} +div.imageblock, div.exampleblock, div.verseblock, +div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, +div.admonitionblock { + margin-top: 1.0em; + margin-bottom: 1.5em; +} +div.admonitionblock { + margin-top: 2.0em; + margin-bottom: 2.0em; + margin-right: 10%; + color: #606060; +} + +div.content { /* Block element content. */ + padding: 0; +} + +/* Block element titles. */ +div.title, caption.title { + color: #527bbd; + font-weight: bold; + text-align: left; + margin-top: 1.0em; + margin-bottom: 0.5em; +} +div.title + * { + margin-top: 0; +} + +td div.title:first-child { + margin-top: 0.0em; +} +div.content div.title:first-child { + margin-top: 0.0em; +} +div.content + div.title { + margin-top: 0.0em; +} + +div.sidebarblock > div.content { + background: #ffffee; + border: 1px solid #dddddd; + border-left: 4px solid #f0f0f0; + padding: 0.5em; +} + +div.listingblock > div.content { + border: 1px solid #dddddd; + border-left: 5px solid #f0f0f0; + background: #f8f8f8; + padding: 0.5em; +} + +div.quoteblock, div.verseblock { + padding-left: 1.0em; + margin-left: 1.0em; + margin-right: 10%; + border-left: 5px solid #f0f0f0; + color: #888; +} + +div.quoteblock > div.attribution { + padding-top: 0.5em; + text-align: right; +} + +div.verseblock > pre.content { + font-family: inherit; + font-size: inherit; +} +div.verseblock > div.attribution { + padding-top: 0.75em; + text-align: left; +} +/* DEPRECATED: Pre version 8.2.7 verse style literal block. */ +div.verseblock + div.attribution { + text-align: left; +} + +div.admonitionblock .icon { + vertical-align: top; + font-size: 1.1em; + font-weight: bold; + text-decoration: underline; + color: #527bbd; + padding-right: 0.5em; +} +div.admonitionblock td.content { + padding-left: 0.5em; + border-left: 3px solid #dddddd; +} + +div.exampleblock > div.content { + border-left: 3px solid #dddddd; + padding-left: 0.5em; +} + +div.imageblock div.content { padding-left: 0; } +span.image img { border-style: none; vertical-align: text-bottom; } +a.image:visited { color: white; } + +dl { + margin-top: 0.8em; + margin-bottom: 0.8em; +} +dt { + margin-top: 0.5em; + margin-bottom: 0; + font-style: normal; + color: navy; +} +dd > *:first-child { + margin-top: 0.1em; +} + +ul, ol { + list-style-position: outside; +} +ol.arabic { + list-style-type: decimal; +} +ol.loweralpha { + list-style-type: lower-alpha; +} +ol.upperalpha { + list-style-type: upper-alpha; +} +ol.lowerroman { + list-style-type: lower-roman; +} +ol.upperroman { + list-style-type: upper-roman; +} + +div.compact ul, div.compact ol, +div.compact p, div.compact p, +div.compact div, div.compact div { + margin-top: 0.1em; + margin-bottom: 0.1em; +} + +tfoot { + font-weight: bold; +} +td > div.verse { + white-space: pre; +} + +div.hdlist { + margin-top: 0.8em; + margin-bottom: 0.8em; +} +div.hdlist tr { + padding-bottom: 15px; +} +dt.hdlist1.strong, td.hdlist1.strong { + font-weight: bold; +} +td.hdlist1 { + vertical-align: top; + font-style: normal; + padding-right: 0.8em; + color: navy; +} +td.hdlist2 { + vertical-align: top; +} +div.hdlist.compact tr { + margin: 0; + padding-bottom: 0; +} + +.comment { + background: yellow; +} + +.footnote, .footnoteref { + font-size: 0.8em; +} + +span.footnote, span.footnoteref { + vertical-align: super; +} + +#footnotes { + margin: 20px 0 20px 0; + padding: 7px 0 0 0; +} + +#footnotes div.footnote { + margin: 0 0 5px 0; +} + +#footnotes hr { + border: none; + border-top: 1px solid silver; + height: 1px; + text-align: left; + margin-left: 0; + width: 20%; + min-width: 100px; +} + +div.colist td { + padding-right: 0.5em; + padding-bottom: 0.3em; + vertical-align: top; +} +div.colist td img { + margin-top: 0.3em; +} + +@media print { + #footer-badges { display: none; } +} + +#toc { + margin-bottom: 2.5em; +} + +#toctitle { + color: #527bbd; + font-size: 1.1em; + font-weight: bold; + margin-top: 1.0em; + margin-bottom: 0.1em; +} + +div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { + margin-top: 0; + margin-bottom: 0; +} +div.toclevel2 { + margin-left: 2em; + font-size: 0.9em; +} +div.toclevel3 { + margin-left: 4em; + font-size: 0.9em; +} +div.toclevel4 { + margin-left: 6em; + font-size: 0.9em; +} + +span.aqua { color: aqua; } +span.black { color: black; } +span.blue { color: blue; } +span.fuchsia { color: fuchsia; } +span.gray { color: gray; } +span.green { color: green; } +span.lime { color: lime; } +span.maroon { color: maroon; } +span.navy { color: navy; } +span.olive { color: olive; } +span.purple { color: purple; } +span.red { color: red; } +span.silver { color: silver; } +span.teal { color: teal; } +span.white { color: white; } +span.yellow { color: yellow; } + +span.aqua-background { background: aqua; } +span.black-background { background: black; } +span.blue-background { background: blue; } +span.fuchsia-background { background: fuchsia; } +span.gray-background { background: gray; } +span.green-background { background: green; } +span.lime-background { background: lime; } +span.maroon-background { background: maroon; } +span.navy-background { background: navy; } +span.olive-background { background: olive; } +span.purple-background { background: purple; } +span.red-background { background: red; } +span.silver-background { background: silver; } +span.teal-background { background: teal; } +span.white-background { background: white; } +span.yellow-background { background: yellow; } + +span.big { font-size: 2em; } +span.small { font-size: 0.6em; } + +span.underline { text-decoration: underline; } +span.overline { text-decoration: overline; } +span.line-through { text-decoration: line-through; } + +div.unbreakable { page-break-inside: avoid; } + + +/* + * xhtml11 specific + * + * */ + +div.tableblock { + margin-top: 1.0em; + margin-bottom: 1.5em; +} +div.tableblock > table { + border: 3px solid #527bbd; +} +thead, p.table.header { + font-weight: bold; + color: #527bbd; +} +p.table { + margin-top: 0; +} +/* Because the table frame attribute is overridden by CSS in most browsers. */ +div.tableblock > table[frame="void"] { + border-style: none; +} +div.tableblock > table[frame="hsides"] { + border-left-style: none; + border-right-style: none; +} +div.tableblock > table[frame="vsides"] { + border-top-style: none; + border-bottom-style: none; +} + + +/* + * html5 specific + * + * */ + +table.tableblock { + margin-top: 1.0em; + margin-bottom: 1.5em; +} +thead, p.tableblock.header { + font-weight: bold; + color: #527bbd; +} +p.tableblock { + margin-top: 0; +} +table.tableblock { + border-width: 3px; + border-spacing: 0px; + border-style: solid; + border-color: #527bbd; + border-collapse: collapse; +} +th.tableblock, td.tableblock { + border-width: 1px; + padding: 4px; + border-style: solid; + border-color: #527bbd; +} + +table.tableblock.frame-topbot { + border-left-style: hidden; + border-right-style: hidden; +} +table.tableblock.frame-sides { + border-top-style: hidden; + border-bottom-style: hidden; +} +table.tableblock.frame-none { + border-style: hidden; +} + +th.tableblock.halign-left, td.tableblock.halign-left { + text-align: left; +} +th.tableblock.halign-center, td.tableblock.halign-center { + text-align: center; +} +th.tableblock.halign-right, td.tableblock.halign-right { + text-align: right; +} + +th.tableblock.valign-top, td.tableblock.valign-top { + vertical-align: top; +} +th.tableblock.valign-middle, td.tableblock.valign-middle { + vertical-align: middle; +} +th.tableblock.valign-bottom, td.tableblock.valign-bottom { + vertical-align: bottom; +} + + +/* + * manpage specific + * + * */ + +body.manpage h1 { + padding-top: 0.5em; + padding-bottom: 0.5em; + border-top: 2px solid silver; + border-bottom: 2px solid silver; +} +body.manpage h2 { + border-style: none; +} +body.manpage div.sectionbody { + margin-left: 3em; +} + +@media print { + body.manpage div#toc { display: none; } +} + + +</style> +<script type="text/javascript"> +/*<+'])'); + // Function that scans the DOM tree for header elements (the DOM2 + // nodeIterator API would be a better technique but not supported by all + // browsers). + var iterate = function (el) { + for (var i = el.firstChild; i != null; i = i.nextSibling) { + if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { + var mo = re.exec(i.tagName); + if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { + result[result.length] = new TocEntry(i, getText(i), mo[1]-1); + } + iterate(i); + } + } + } + iterate(el); + return result; + } + + var toc = document.getElementById("toc"); + if (!toc) { + return; + } + + // Delete existing TOC entries in case we're reloading the TOC. + var tocEntriesToRemove = []; + var i; + for (i = 0; i < toc.childNodes.length; i++) { + var entry = toc.childNodes[i]; + if (entry.nodeName.toLowerCase() == 'div' + && entry.getAttribute("class") + && entry.getAttribute("class").match(/^toclevel/)) + tocEntriesToRemove.push(entry); + } + for (i = 0; i < tocEntriesToRemove.length; i++) { + toc.removeChild(tocEntriesToRemove[i]); + } + + // Rebuild TOC entries. + var entries = tocEntries(document.getElementById("content"), toclevels); + for (var i = 0; i < entries.length; ++i) { + var entry = entries[i]; + if (entry.element.id == "") + entry.element.id = "_toc_" + i; + var a = document.createElement("a"); + a.href = "#" + entry.element.id; + a.appendChild(document.createTextNode(entry.text)); + var div = document.createElement("div"); + div.appendChild(a); + div.className = "toclevel" + entry.toclevel; + toc.appendChild(div); + } + if (entries.length == 0) + toc.parentNode.removeChild(toc); +}, + + +///////////////////////////////////////////////////////////////////// +// Footnotes generator +///////////////////////////////////////////////////////////////////// + +/* Based on footnote generation code from: + * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html + */ + +footnotes: function () { + // Delete existing footnote entries in case we're reloading the footnodes. + var i; + var noteholder = document.getElementById("footnotes"); + if (!noteholder) { + return; + } + var entriesToRemove = []; + for (i = 0; i < noteholder.childNodes.length; i++) { + var entry = noteholder.childNodes[i]; + if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") + entriesToRemove.push(entry); + } + for (i = 0; i < entriesToRemove.length; i++) { + noteholder.removeChild(entriesToRemove[i]); + } + + // Rebuild footnote entries. + var cont = document.getElementById("content"); + var spans = cont.getElementsByTagName("span"); + var refs = {}; + var n = 0; + for (i=0; i<spans.length; i++) { + if (spans[i].className == "footnote") { + n++; + var note = spans[i].getAttribute("data-note"); + if (!note) { + // Use [\s\S] in place of . so multi-line matches work. + // Because JavaScript has no s (dotall) regex flag. + note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1]; + spans[i].innerHTML = + "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n + + "' title='View footnote' class='footnote'>" + n + "</a>]"; + spans[i].setAttribute("data-note", note); + } + noteholder.innerHTML += + "<div class='footnote' id='_footnote_" + n + "'>" + + "<a href='#_footnoteref_" + n + "' title='Return to text'>" + + n + "</a>. " + note + "</div>"; + var id =spans[i].getAttribute("id"); + if (id != null) refs["#"+id] = n; + } + } + if (n == 0) + noteholder.parentNode.removeChild(noteholder); + else { + // Process footnoterefs. + for (i=0; i<spans.length; i++) { + if (spans[i].className == "footnoteref") { + var href = spans[i].getElementsByTagName("a")[0].getAttribute("href"); + href = href.match(/#.*/)[0]; // Because IE return full URL. + n = refs[href]; + spans[i].innerHTML = + "[<a href='#_footnote_" + n + + "' title='View footnote' class='footnote'>" + n + "</a>]"; + } + } + } +}, + +install: function(toclevels) { + var timerId; + + function reinstall() { + asciidoc.footnotes(); + if (toclevels) { + asciidoc.toc(toclevels); + } + } + + function reinstallAndRemoveTimer() { + clearInterval(timerId); + reinstall(); + } + + timerId = setInterval(reinstall, 500); + if (document.addEventListener) + document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); + else + window.onload = reinstallAndRemoveTimer; +} + +} +asciidoc.install(4); +/*]]>*/ +</script> +</head> +<body class="article"> +<div id="header"> +<h1>Tutorial for the Next Scripting Language</h1> +<span id="author">Gustaf Neumann <neumann@wu-wien.ac.at>, Stefan Sobernig <stefan.sobernig@wu.ac.at></span><br /> +<span id="revnumber">version 2.2.0,</span> +<span id="revdate">September 2018</span> +<br /><span id="revremark">Written for the Initial Release of the Next Scripting Framework.</span> <div id="toc"> <div id="toctitle">Table of Contents</div> <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript> -</div> -</div> -<div id="content"> -<div id="preamble"> -<div class="sectionbody"> -<div class="sidebarblock"> -<div class="content"> -<div class="title">Abstract</div> -<div class="paragraph"><p>This document provides a tutorial for the Next Scripting -Language NX.</p></div> -</div></div> -<div class="paragraph"><p>The Next Scripting Language (NX) is a highly flexible object oriented -scripting language based on Tcl <a href="#Ousterhout 1990">[Ousterhout 1990]</a>. NX is a successor -of XOTcl 1 <a href="#Neumann and Zdun 2000a">[Neumann and Zdun 2000a]</a> and was developed based on 10 -years of experience with XOTcl in projects containing several hundred -thousand lines of code. While XOTcl was the first language designed to -provide <em>language support for design patterns</em>, the focus of the Next -Scripting Framework and NX is on combining this with <em>Language -Oriented Programming</em>. In many respects, NX was designed to ease the -learning of the language for novices (by using a more mainstream -terminology, higher orthogonality of the methods, less predefined -methods), to improve maintainability (remove sources of common errors) -and to encourage developers to write better structured programs (to -provide interfaces) especially for large projects, where many -developers are involved.</p></div> -<div class="paragraph"><p>The Next Scripting Language is based on the Next Scripting Framework -(NSF) which was developed based on the notion of language oriented -programming. The Next Scripting Frameworks provides C-level support -for defining and hosting multiple object systems in a single Tcl -interpreter. The name of the Next Scripting Framework is derived from -the universal method combinator "next", which was introduced in XOTcl. -The combinator "next" serves as a single instrument for method -combination with filters, per-object and transitive per-class mixin -classes, object methods and multiple inheritance.</p></div> -<div class="paragraph"><p>The definition of NX is fully scripted (e.g. defined in -<code>nx.tcl</code>). The Next Scripting Framework is shipped with three language -definitions, containing NX and XOTcl 2. Most of the existing XOTcl 1 -programs can be used without modification in the Next Scripting -Framework by using XOTcl 2. The Next Scripting Framework requires Tcl -8.5 or newer.</p></div> -</div> -</div> -<div class="sect1"> -<h2 id="_nx_and_its_roots">1. NX and its Roots</h2> -<div class="sectionbody"> -<div class="paragraph"><p>Object oriented extensions of Tcl have quite a -long history. Two of the most prominent early Tcl based OO languages -were <em>incr Tcl</em> (abbreviated as itcl) and Object Tcl (<em>OTcl</em> -<a href="#Wetherall and Lindblad 1995">[Wetherall and Lindblad 1995]</a>). While itcl provides a traditional -C++/Java-like object system, OTcl was following the CLOS approach and -supports a dynamic object system, allowing incremental class and -object extensions and re-classing of objects.</p></div> -<div class="paragraph"><p>Extended Object Tcl (abbreviated as XOTcl <a href="#Neumann and Zdun 2000a">[Neumann and Zdun 2000a]</a>) -is a successor of OTcl and was the first language providing language -support for design patterns. XOTcl extends OTcl by providing namespace -support, adding assertions, dynamic object aggregations, slots and by -introducing per-object and per-class filters and per-object and -per-class mixins.</p></div> -<div class="paragraph"><p>XOTcl was so far released in more than 30 versions. It is described in -its detail in more than 20 papers and serves as a basis for other -object systems like TclOO [Donal ???]. The scripting language <em>NX</em> and -the <em>Next Scripting Framework</em> <a href="#Neumann and Sobernig 2009">[Neumann and Sobernig 2009]</a> extend -the basic ideas of XOTcl by providing support for <em>language-oriented -programming</em>. The the Next Scripting Framework supports multiple -object systems concurrently. Effectively, every object system has -different base classes for creating objects and classes. Therefore, -these object systems can have different interfaces and can -follow different naming conventions for built-in methods. Currently, -the Next Scripting Framework is packaged with three object systems: -NX, XOTcl 2.0, and TclCool (the language introduced by TIP#279).</p></div> -<div class="imageblock" style="text-align:center;"> -<div class="content"> -<img src="languages.png" alt="Languages" width="500" /> -</div> -<div class="title">Figure 1. Language History of the Next Scripting Language</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p>The primary purpose of this document is to introduce NX to beginners. -We expect some prior knowledge of programming languages, and some -knowledge about Tcl. In the following sections we introduce NX by -examples. In later sections we introduce the more advanced concepts of -the language. Conceptually, most of the addressed concepts are very -similar to XOTcl. Concerning the differences between NX and XOTcl, -please refer to the <em>Migration Guide for the Next Scripting Language</em>.</p></div> -</div> -</div> -<div class="sect1"> -<h2 id="_introductory_overview_example_stack">2. Introductory Overview Example: Stack</h2> -<div class="sectionbody"> -<div class="paragraph"><p>A classical programming example is the implementation of a stack, which -is most likely familiar to many readers from many introductory -programming courses. A stack is a last-in first-out data structure -which is manipulated via operations like <code>push</code> (add something to the -stack) and <code>pop</code> remove an entry from the stack. These operations are -called <em>methods</em> in the context of object oriented programming -systems. Primary goals of object orientation are encapsulation and -abstraction. Therefore, we define a common unit (a class) that defines -and encapsulates the behavior of a stack and provides methods to a user -of the data structure that abstract from the actual implementation.</p></div> -<div class="sect2"> -<h3 id="_define_a_class_stack">2.1. Define a Class "Stack"</h3> -<div class="paragraph"><p>In our first example, we define a class named <code>Stack</code> with the methods -<code>push</code> and <code>pop</code>. When an instance of the stack is created (e.g. a -concrete stack <code>s1</code>) the stack will contain an instance variable named -<code>things</code>, initialized with the an empty list.</p></div> -<div class="paragraph" id="xmp-class-stack"><div class="title">Listing 2: Class Stack</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Stack { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Stack of Things -</span> <span class='nx-comment'># -</span> - <span class='nx-keyword'>:variable</span> things {} - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing} { - <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0 <span class='nx-variable'>$thing</span>] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> - } - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> pop {} { - <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0] - <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 1 end] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$top</span> - } -}</pre></div></div> -<div class="paragraph"><p>Typically, classes are defined in NX via <code>nx::Class create</code>, followed -by the name of the new class (here: <code>Stack</code>). The definition of the -stack placed between curly braces and contains here just the method -definitions. Methods of the class are defined via <code>:method</code> followed -by the name of the method, an argument list and the body of the -method, consisting of Tcl and NX statements.</p></div> -<div class="paragraph"><p>When an instance of <code>Stack</code> is created, it will contain an instance -variable named <code>things</code>. If several <code>Stack</code> instances are created, -each of the instances will have their own (same-named but different) -instance variable. The instance variable <code>things</code> is used in our -example as a list for the internal representation of the stack. We -define in a next step the methods to access and modify this list -structure. A user of the stack using the provided methods does not -have to have any knowledge about the name or the structure of the -internal representation (the instance variable <code>things</code>).</p></div> -<div class="paragraph"><p>The method <code>push</code> receives an argument <code>thing</code> which should be placed -on the stack. Note that we do not have to specify the type of the -element on the stack, so we can push strings as well as numbers or -other kind of things. When an element is pushed, we add this element -as the first element to the list <code>things</code>. We insert the element using -the Tcl command <code>linsert</code> which receives the list as first element, -the position where the element should be added as second and the new -element as third argument. To access the value of the instance -variable we use Tcl’s dollar operator followed by the name. The -names of instance variables are preceded with a colon <code>:</code>. Since the -name contains a non-plain character, Tcl requires us to put braces -around the name. The command <code>linsert</code> and its arguments are placed -between square brackets. This means that the function <code>linsert</code> is called and -a new list is returned, where the new element is inserted at the first -position (index 0) in the list <code>things</code>. The result of the <code>linsert</code> -function is assigned again to the instance variable <code>things</code>, which is -updated this way. Finally the method <code>push</code> returns the pushed thing -using the <code>return</code> statement.</p></div> -<div class="paragraph"><p>The method <code>pop</code> returns the most recently stacked element and removes -it from the stack. Therefore, it takes the first element from the list -(using the Tcl command <code>lindex</code>), assigns it to the method-scoped -variable <code>top</code>, removes the element from the instance variable -<code>things</code> (by using the Tcl command <code>lrange</code>) and returns the value -popped element <code>top</code>.</p></div> -<div class="paragraph"><p>This finishes our first implementation of the stack, more enhanced -versions will follow. Note that the methods <code>push</code> and <code>pop</code> are -defined as <code>public</code>; this means that these methods can be -used from all other objects in the system. Therefore, these methods -provide an interface to the stack implementation.</p></div> -<div class="paragraph" id="xmp-using-stack"><div class="title">Listing 3: Using the Stack</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'>#!/usr/bin/env tclsh -</span><span class='nx-keyword'>package</span> <span class='nx-keyword'>require</span> nx - -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Stack { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Stack of Things -</span> <span class='nx-comment'># -</span> .... -} - -Stack <span class='nx-keyword'>create</span> s1 -s1 push a -s1 push b -s1 push c -<span class='nx-keyword'>puts</span> [s1 pop] -<span class='nx-keyword'>puts</span> [s1 pop] -s1 <span class='nx-keyword'>destroy</span></pre></div></div> -<div class="paragraph"><p>Now we want to use the stack. The code snippet in <a href="#xmp-using-stack">Listing 3</a> shows how to use the class Stack in a script. -Since NX is based on Tcl, the script will be called with the Tcl shell -<code>tclsh</code>. In the Tcl shell we have to <code>require package nx</code> to use the -Next Scripting Framework and NX. The next lines contain the definition -of the stack as presented before. Of course, it is as well possible to -make the definition of the stack an own package, such we could simple -say <code>package require stack</code>, or to save the definition of a stack -simply in a file and load it via <code>source</code>.</p></div> -<div class="paragraph"><p>In line 12 we create an instance of the stack, namely the stack object -<code>s1</code>. The object <code>s1</code> is an instance of <code>Stack</code> and has therefore -access to its methods. The methods like <code>push</code> or <code>pop</code> can be invoked -via a command starting with the object name followed by the -method name. In lines 13-15 we push on the stack the values <code>a</code>, then -<code>b</code>, and <code>c</code>. In line 16 we output the result of the <code>pop</code> method -using the Tcl command <code>puts</code>. We will see on standard output the -value+c+ (the last stacked item). The output of the line 17 is the -value <code>b</code> (the previously stacked item). Finally, in line 18 we -destroy the object. This is not necessary here, but shows the life -cycle of an object. In some respects, <code>destroy</code> is the counterpart of -<code>create</code> from line 12.</p></div> -<div class="imageblock" id="fig-class-object" style="text-align:center;"> -<div class="content"> -<img src="object-class-appclass.png" alt="object-class-appclass.png" /> -</div> -<div class="title">Figure 4. Class and Object Diagram</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p><a href="#fig-class-object">Figure 4</a> shows the actual class and -object structure of the first <code>Stack</code> example. Note that the common -root class is <code>nx::Object</code> that contains methods for all objects. -Since classes are as well objects in NX, <code>nx::Class</code> is a -specialization of <code>nx::Object</code>. <code>nx::Class</code> provides methods for -creating objects, such as the method <code>create</code> which is used to create -objects (and classes as well).</p></div> -</div> -<div class="sect2"> -<h3 id="_define_an_object_named_stack">2.2. Define an Object Named "stack"</h3> -<div class="paragraph"><p>The definition of the stack in <a href="#xmp-class-stack">Listing 2</a> -follows the traditional object oriented approach, found in -practically every object oriented programming language: Define a class -with some methods, create instances from this class, and use the -methods defined in the class in the instances of the class.</p></div> -<div class="paragraph"><p>In our next example, we introduce <em>generic objects</em> and <em>object -specific methods</em>. With NX, we can define generic objects, which are -instances of the most generic class <code>nx::Object</code> (sometimes called -<em>common root class</em>). <code>nx::Object</code> is predefined and contains a -minimal set of methods applicable to all NX objects. In this example, -we define a generic object named <code>stack</code> and provide methods for this -object. The methods defined above were methods provided by a class for -objects. Now we define object specific methods, which are methods -applicable only to the object for which they are defined.</p></div> -<div class="paragraph" id="xmp-object-stack"><div class="title">Listing 5: Object stack</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> stack { - - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>variable</span> things {} - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> push {thing} { - <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0 <span class='nx-variable'>$thing</span>] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> - } - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> pop {} { - <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0] - <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 1 end] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$top</span> - } -}</pre></div></div> -<div class="paragraph"><p>The example in <a href="#xmp-object-stack">Listing 5</a> defines the -object <code>stack</code> in a very similar way as the class <code>Stack</code>. But the -following points are different.</p></div> -<div class="ulist"><ul> -<li> -<p> -First, we use <code>nx::Object</code> instead of <code>nx::Class</code> to denote - that we want to create a generic object, not a class. -</p> -</li> -<li> -<p> -We use <code>:object variable</code> to define the variable <code>things</code> just for - this single instance (the object <code>stack</code>). -</p> -</li> -<li> -<p> -The definition for the methods <code>push</code> and <code>pop</code> are the same as - before, but here we defined these with <code>object method</code>. Therefore, - these two methods <code>push</code> and <code>pop</code> are object-specific. -</p> -</li> -</ul></div> -<div class="paragraph"><p>In order to use -the stack, we can use directly the object <code>stack</code> in the same way as -we have used the object <code>s1</code> in <a href="#xmp-using-stack">Listing 3</a> -the class diagram for this the object <code>stack</code>.</p></div> -<div class="imageblock" id="img-object-stack" style="text-align:center;"> -<div class="content"> -<img src="object-stack.png" alt="object-stack.png" /> -</div> -<div class="title">Figure 6. Object stack</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p>A reader might wonder when to use a class <code>Stack</code> or rather an object -<code>stack</code>. A big difference is certainly that one can define easily -multiple instances of a class, while the object is actually a -single, tailored entity. The concept of the object <code>stack</code> is similar to a module, -providing a certain functionality via a common interface, without -providing the functionality to create multiple instances. The reuse of -methods provided by the class to objects is as well a difference. If -the methods of the class are updated, all instances of the class will -immediately get the modified behavior. However, this does not mean that -the reuse for the methods of <code>stack</code> is not possible. NX allows for -example to copy objects (similar to prototype based languages) or to -reuse methods via e.g. aliases (more about this later).</p></div> -<div class="paragraph"><p>Note that we use capitalized names for classes and lowercase names for -instances. This is not required and a pure convention making it easier -to understand scripts without much analysis.</p></div> -</div> -<div class="sect2"> -<h3 id="_implementing_features_using_mixin_classes">2.3. Implementing Features using Mixin Classes</h3> -<div class="paragraph"><p>So far, the definition of the stack methods was pretty minimal. -Suppose, we want to define "safe stacks" that protect e.g. against -stack under-runs (a stack under-run happens, when more <code>pop</code> than -<code>push</code> operations are issued on a stack). Safety checking can be -implemented mostly independent from the implementation details of the -stack (usage of internal data structures). There are as well different -ways of checking the safety. Therefore we say that safety checking is -orthogonal to the stack core implementation.</p></div> -<div class="paragraph"><p>With NX we can define stack-safety as a separate class using methods -with the same names as the implementations before, and "mix" this -behavior into classes or objects. The implementation of <code>Safety</code> in -stack under-runs and to issue error messages, when this happens.</p></div> -<div class="paragraph" id="xmp-class-safety"><div class="title">Listing 7: Class Safety</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Safety { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Implement stack safety by defining an additional -</span> <span class='nx-comment'># instance variable named "count" that keeps track of -</span> <span class='nx-comment'># the number of stacked elements. The methods of -</span> <span class='nx-comment'># this class have the same names and argument lists -</span> <span class='nx-comment'># as the methods of Stack; these methods "shadow" -</span> <span class='nx-comment'># the methods of class Stack. -</span> <span class='nx-comment'># -</span> - <span class='nx-keyword'>:variable</span> count 0 - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing} { - <span class='nx-keyword'>incr</span> :count - <span class='nx-keyword'>next</span> - } - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> pop {} { - <span class='nx-keyword'>if</span> {<span class='nx-variable'>${</span><span class='nx-variable'>:count}</span> == 0} { <span class='nx-keyword'>error</span> <span class='nx-string'>"Stack empty!"</span> } - <span class='nx-keyword'>incr</span> :count -1 - <span class='nx-keyword'>next</span> - } -}</pre></div></div> -<div class="paragraph"><p>Note that all the methods of the class <code>Safety</code> end with <code>next</code>. -This command is a primitive command of NX, which calls the -same-named method with the same argument list as the current -invocation.</p></div> -<div class="paragraph"><p>Assume we save the definition of the class <code>Stack</code> in a file named -<code>Stack.tcl</code> and the definition of the class <code>Safety</code> in a file named -<code>Safety.tcl</code> in the current directory. When we load the classes -<code>Stack</code> and <code>Safety</code> into the same script (see the terminal dialog in -e.g. a certain stack <code>s2</code> as a safe stack, while all other stacks -(such as <code>s1</code>) might be still "unsafe". This can be achieved via the -option <code>-mixin</code> at the object creation time (see line 9 in -option <code>-mixin</code> mixes the class <code>Safety</code> into the new instance <code>s2</code>.</p></div> -<div class="paragraph" id="xmp-using-class-safety"><div class="title">Listing 8: Using the Class Safety</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>% <span class='nx-keyword'>package</span> <span class='nx-keyword'>require</span> nx -2.0 -% <span class='nx-keyword'>source</span> Stack.tcl -::Stack -% <span class='nx-keyword'>source</span> Safety.tcl -::Safety -% Stack <span class='nx-keyword'>create</span> s1 -::s1 -% Stack <span class='nx-keyword'>create</span> s2 -object-mixin Safety -::s2 -% s2 push a -% s2 pop -a -% s2 pop -Stack empty! - -% s1 <span class='nx-keyword'>info</span> precedence -::Stack ::nx::Object - -% s2 <span class='nx-keyword'>info</span> precedence -::Safety ::Stack ::nx::Object</pre></div></div> -<div class="paragraph"><p>When the method <code>push</code> of <code>s2</code> is called, first the method of the -mixin class <code>Safety</code> will be invoked that increments the counter and -continues with <code>next</code> to call the shadowed method, here the method -<code>push</code> of the <code>Stack</code> implementation that actually pushes the item. -The same happens, when <code>s2 pop</code> is invoked, first the method of -<code>Safety</code> is called, then the method of the <code>Stack</code>. When the stack is -empty (the value of <code>count</code> reaches 0), and <code>pop</code> is invoked, the -mixin class <code>Safety</code> generates an error message (raises an exception), -and does not invoke the method of the <code>Stack</code>.</p></div> -<div class="paragraph"><p>The last two commands in -<a href="#xmp-using-class-safety">Listing 8</a> -use introspection to query for the objects -<code>s1</code> and <code>s2</code> in which order the involved classes are processed. This -order is called the <code>precedence order</code> and is obtained via <code>info -precedence</code>. We see that the mixin class <code>Safety</code> is only in use for -<code>s2</code>, and takes there precedence over <code>Stack</code>. The common root class -<code>nx::Object</code> is for both <code>s1</code> and <code>s2</code> the base class.</p></div> -<div class="imageblock" id="img-per-object-mixin" style="text-align:center;"> -<div class="content"> -<img src="per-object-mixin.png" alt="per-object-mixin.png" /> -</div> -<div class="title">Figure 9. Per-object Mixin</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p>Note that in <a href="#xmp-using-class-safety">Listing 8</a>, -the class <code>Safety</code> is only mixed into a single object (here -<code>s2</code>), therefore we refer to this case as a <em>per-object mixin</em>. -<a href="#img-per-object-mixin">Figure 9</a> shows the class -diagram, where the class <code>Safety</code> is used as a per-object mixin for -<code>s2</code>.</p></div> -<div class="paragraph"><p>The mixin class <code>Safety</code> can be used as well in other ways, such as e.g. for -defining classes of safe stacks:</p></div> -<div class="paragraph" id="xmp-class-safestack"><div class="title">Listing 10: Class SafeStack</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># Create a safe stack class by using Stack and mixin -</span><span class='nx-comment'># Safety -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> SafeStack -superclasses Stack -mixins Safety - -SafeStack <span class='nx-keyword'>create</span> s3</pre></div></div> -<div class="paragraph"><p>The difference of a per-class mixin and a per-object mixin is that -the per-class mixin is applicable to all instances of the -class. Therefore, we call these mixins also sometimes instance mixins. -In our example in <a href="#xmp-class-safestack">Listing 10</a>, -<code>Safety</code> is mixed into the definition of -<code>SafeStack</code>. Therefore, all instances of the class <code>SafeStack</code> (here -the instance <code>s3</code>) will be using the safety definitions.</p></div> -<div class="imageblock" id="img-per-class-mixin" style="text-align:center;"> -<div class="content"> -<img src="per-class-mixin.png" alt="per-class-mixin.png" /> -</div> -<div class="title">Figure 11. Per-class Mixin</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p><a href="#img-per-class-mixin">Figure 11</a> shows the class diagram -for this definition. -Note that we could use <code>Safety</code> as well as a per-class mixin on -<code>Stack</code>. In this case, all stacks would be safe stacks and we could -not provide a selective feature selection (which might be perfectly -fine).</p></div> -</div> -<div class="sect2"> -<h3 id="_define_different_kinds_of_stacks">2.4. Define Different Kinds of Stacks</h3> -<div class="paragraph"><p>The definition of <code>Stack</code> is generic and allows all kind of elements -to be stacked. Suppose, we want to use the generic stack definition, -but a certain stack (say, stack <code>s4</code>) should be a stack for integers -only. This behavior can be achieved by the same means as introduced -already in <a href="#xmp-object-stack">Listing 5</a>, namely -object-specific methods.</p></div> -<div class="paragraph" id="xmp-object-integer-stack"><div class="title">Listing 12: Object Integer Stack</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>Stack <span class='nx-keyword'>create</span> s4 { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Create a stack with a object-specific method -</span> <span class='nx-comment'># to check the type of entries -</span> <span class='nx-comment'># -</span> - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> push {thing:integer} { - <span class='nx-keyword'>next</span> - } -}</pre></div></div> -<div class="paragraph"><p>The program snippet in <a href="#xmp-object-integer-stack">Listing 12</a> defines an instance <code>s4</code> of the class -<code>Stack</code> and provides an object specific method for <code>push</code> to implement -an integer stack. The method <code>pull</code> is the same for the integer stack -as for all other stacks, so it will be reused as usual from the class -<code>Stack</code>. The object-specific method <code>push</code> of <code>s4</code> has a value -constraint in its argument list (<code>thing:integer</code>) that makes sure -that only integers can be stacked. In case the argument is not an -integer, an exception will be raised. Of course, one could perform the -value constraint checking as well in the body of the method <code>proc</code> by -accepting an generic argument and by performing the test for the value -in the body of the method. In the case, the passed value is an -integer, the <code>push</code> method of <a href="#xmp-object-integer-stack">Listing 12</a> calls <code>next</code>, and therefore calls the -shadowed generic definition of <code>push</code> as provided by <code>Stack</code>.</p></div> -<div class="paragraph" id="xmp-class-integer-stack"><div class="title">Listing 13: Class IntegerStack</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> IntegerStack -superclass Stack { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Create a Stack accepting only integers -</span> <span class='nx-comment'># -</span> - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing:integer} { - <span class='nx-keyword'>next</span> - } -}</pre></div></div> -<div class="paragraph"><p>An alternative approach is shown in -<a href="#xmp-class-integer-stack">Listing 13</a>, where the class -<code>IntegerStack</code> is defined, using the same method definition -as <code>s4</code>, this time on the class level.</p></div> -</div> -<div class="sect2"> -<h3 id="_define_object_specific_methods_on_classes">2.5. Define Object Specific Methods on Classes</h3> -<div class="paragraph"><p>In our previous examples we defined methods provided by classes -(applicable for their instances) and object-specific methods (methods -defined on objects, which are only applicable for these objects). In -this section, we introduce methods that are defined on the class -objects. Such methods are sometimes called <em>class methods</em> or -<em>static methods</em>.</p></div> -<div class="paragraph"><p>In NX classes are objects, they are specialized objects with -additional methods. Methods for classes are often used for managing -the life-cycles of the instances of the classes (we will come to this -point in later sections in more detail). Since classes are objects, we -can use exactly the same notation as above to define class methods by -using <code>object method</code>. The methods defined on the class object are -in all respects identical with object specific methods shown in the -examples above.</p></div> -<div class="paragraph" id="xmp-stack2"><div class="title">Listing 14: Class Stack2</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Stack2 { - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> available_stacks {} { - <span class='nx-keyword'>return</span> [<span class='nx-keyword'>llength</span> [<span class='nx-keyword'>:info</span> instances]] - } - - <span class='nx-keyword'>:variable</span> things {} - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing} { - <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0 <span class='nx-variable'>$thing</span>] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> - } - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> pop {} { - <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0] - <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 1 end] - <span class='nx-keyword'>return</span> <span class='nx-variable'>$top</span> - } -} - -Stack2 <span class='nx-keyword'>create</span> s1 -Stack2 <span class='nx-keyword'>create</span> s2 - -<span class='nx-keyword'>puts</span> [Stack2 available_stacks]</pre></div></div> -<div class="paragraph"><p>The class <code>Stack2</code> in <a href="#xmp-stack2">Listing 14</a> consists of the -earlier definition of the class <code>Stack</code> and is extended by the -class-specific method <code>available_stacks</code>, which returns the -current number of instances of the stack. The final command <code>puts</code> -(line 26) prints 2 to the console.</p></div> -<div class="imageblock" id="img-stack2" style="text-align:center;"> -<div class="content"> -<img src="stack2.png" alt="stack2.png" /> -</div> -<div class="title">Figure 15. Stack2</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p>The class diagram in <a href="#img-stack2">Figure 15</a> shows the -diagrammatic representation of the class object-specific method -<code>available_stacks</code>. Since every class is a specialization of the -common root class <code>nx::Object</code>, the common root class is often omitted -from the class diagrams, so it was omitted here as well in the diagram.</p></div> -</div> -</div> -</div> -<div class="sect1"> -<h2 id="_basic_language_features_of_nx">3. Basic Language Features of NX</h2> -<div class="sectionbody"> -<div class="sect2"> -<h3 id="_variables_and_properties">3.1. Variables and Properties</h3> -<div class="paragraph"><p>In general, NX does not need variable declarations. It allows one to -create or modify variables on the fly by using for example the Tcl -commands <code>set</code> and <code>unset</code>. Depending on the variable name (or more -precisely, depending on the variable name’s prefix consisting of -colons "<code>:</code>") a variable is either local to a method, or it is an -instance variable, or a global variable. The rules are:</p></div> -<div class="ulist"><ul> -<li> -<p> -A variable without any colon prefix refers typically to a method - scoped variable. Such a variable is created during the invocation - of the method, and it is deleted, when the method ends. In the - example below, the variable <code>a</code> is method scoped. -</p> -</li> -<li> -<p> -A variable with a single colon prefix refers to an instance - variable. An instance variable is part of the object; when the - object is destroyed, its instance variables are deleted as well. In the - example below, the variable <code>b</code> is an instance variable. -</p> -</li> -<li> -<p> -A variable with two leading colons refers to a global variable. The - lifespan of a globale variable ends when the variable is explicitly - unset or the script terminates. Variables, which are placed in Tcl - namespaces, are also global variables. In the example below, the - variable <code>c</code> is a global variable. -</p> -</li> -</ul></div> -<div class="paragraph" id="xmp-var-resolver"><div class="title">Listing 16: Scopes of Variables</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Foo { - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo args {...} - <span class='nx-comment'># "a" is a method scoped variable -</span> <span class='nx-keyword'>set</span> a 1 - <span class='nx-comment'># "b" is an Instance variable -</span> <span class='nx-keyword'>set</span> :b 2 - <span class='nx-comment'># "c" is a global variable/namespaced variable -</span> <span class='nx-keyword'>set</span> ::c 3 - } -}</pre></div></div> -<div class="paragraph"><p><a href="#xmp-var-resolver">Listing 16</a> shows a method <code>foo</code> -of some class <code>Foo</code> referring to differently scoped variables.</p></div> -<div class="sect3"> -<h4 id="_properties_configurable_instance_variables">3.1.1. Properties: Configurable Instance Variables</h4> -<div class="paragraph"><p>As described above, there is no need to declare instance variables in -NX. In many cases, a developer might want to define some value -constraints for variables, or to provide defaults, or to make -variables configurable upon object creation. Often, variables are -"inherited", meaning that the variables declared in a general class -are also available in a more specialized class. For these purposes NX -provides <em>variable handlers</em> responsible for the management of -instance variables. We distinguish in NX between configurable -variables (called <code>property</code>) and variables that are not configurable -(called <code>variable</code>).</p></div> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>A <strong>property</strong> is a definition of a configurable instance variable.</p></div> -</div></div> -<div class="paragraph"><p>The term configurable means that (a) one can provide at creation time of -an instance a value for this variable, and (b), one can query the -value via the accessor function <code>cget</code> and (c), one can change the -value of the variable via <code>configure</code> at runtime. Since the general -accessor function <code>cget</code> and <code>configure</code> are available, an application -developer does not have to program own accessor methods. When value -checkers are provided, each time, the value of the variable is to be -changed, the constrained are checked as well.</p></div> -<div class="imageblock" id="img-person-student" style="text-align:center;"> -<div class="content"> -<img src="person-student.png" alt="person-student.png" /> -</div> -<div class="title">Figure 17. Classes Person and Student</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p>The class diagram above defines the classes <code>Person</code> and -<code>Student</code>. For both classes, configurable instance variable are -specified by defining these as properties. The listing below shows -an implementation of this conceptual model in NX.</p></div> -<div class="paragraph" id="xmp-properties"><div class="title">Listing 18: Properties</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># Define a class Person with properties "name" -</span><span class='nx-comment'># and "birthday" -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Person { - <span class='nx-keyword'>:property</span> name:required - <span class='nx-keyword'>:property</span> birthday -} - -<span class='nx-comment'># -</span><span class='nx-comment'># Define a class Student as specialization of Person -</span><span class='nx-comment'># with additional properties -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Student -superclass Person { - <span class='nx-keyword'>:property</span> matnr:required - <span class='nx-keyword'>:property</span> {oncampus:boolean true} -} - -<span class='nx-comment'># -</span><span class='nx-comment'># Create instances using configure parameters -</span><span class='nx-comment'># for the initialization -</span><span class='nx-comment'># -</span>Person <span class='nx-keyword'>create</span> p1 -name Bob -Student <span class='nx-keyword'>create</span> s1 -name Susan -matnr 4711 - -<span class='nx-comment'># Access property value via accessor method -</span><span class='nx-keyword'>puts</span> <span class='nx-string'>"The name of s1 is [s1 cget -name]"</span></pre></div></div> -<div class="paragraph"><p>By defining <code>name</code> and <code>birthday</code> as properties of <code>Person</code>, NX makes -these configurable. When we create an instance of <code>Person</code> named -<code>p1</code>, we can provide a value for e.g. the name by specifying <code>-name</code> -during creation. The properties result in non-positional configure parameters -which can be provided in any order. In our listing, we create an instance of -<code>Person</code> using the configure parameter <code>name</code> and provide the value of -<code>Bob</code> to the instance variable <code>name</code>.</p></div> -<div class="paragraph"><p>The class <code>Student</code> is defined as a specialization of <code>Person</code> with -two additional properties: <code>matnr</code> and <code>oncampus</code>. The property -<code>matnr</code> is required (it has to be provided, when an instance of this -class is created), and the property <code>oncampus</code> is boolean, and is per -default set to <code>true</code>. Note that the class <code>Student</code> inherits the -properties of <code>Person</code>. So, <code>Student</code> has four properties in total.</p></div> -<div class="paragraph"><p>The property definitions provide the <code>configure parameters</code> for -instance creation. Many other languages require such parameters to be -passed via arguments of a constructor, which is often error prone, -when values are to be passed to superclasses. Also in dynamic -languages, the relationships between classes can be easily changed, -and different superclasses might have different requirements in their -constructors. The declarative approach in NX reduces the need for -tailored constructor methods significantly.</p></div> -<div class="paragraph"><p>Note that the property <code>matnr</code> of class <code>Student</code> is required. This -means, that if we try to create an instance of <code>Student</code>, a runtime -exception will be triggered. The property <code>oncamups</code> is boolean and -contains a default value. Providing a default value means that -whenever we create an instance of this class the object will contain -such an instance variable, even when we provide no value via the -configure parameters.</p></div> -<div class="paragraph"><p>In our listing, we create an instance of <code>Student</code> using the two -configure parameters <code>name</code> and <code>matnr</code>. Finally, we use method <code>cget</code> -to obtain the value of the instance variable <code>name</code> of object <code>s1</code>.</p></div> -</div> -<div class="sect3"> -<h4 id="_non_configurable_instance_variables">3.1.2. Non-configurable Instance Variables</h4> -<div class="paragraph"><p>In practice, not all instance variables should be configurable. But -still, we want to be able to provide defaults similar to -properties. To define non-configurable instance variables the -predefined method <code>variable</code> can be used. Such instance variables are -often used for e.g. keeping the internal state of an object. The -usage of <code>variable</code> is in many respects similar to <code>property</code>. One -difference is, that <code>property</code> uses the same syntax as for method -parameters, whereas <code>variable</code> receives the default value as a -separate argument (similar to the <code>variable</code> command in plain -Tcl). The introductory Stack example in <a href="#xmp-class-stack">Listing 2</a> uses already the method <code>variable</code>.</p></div> -<div class="paragraph" id="xmp-variable"><div class="title">Listing 19: Declaring Variables</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Base { - <span class='nx-keyword'>:variable</span> x 1 - <span class='nx-comment'># ... -</span>} - -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Derived -superclass Base { - <span class='nx-keyword'>:variable</span> y 2 - <span class='nx-comment'># ... -</span>} - -<span class='nx-comment'># Create instance of the class Derived -</span>Derived <span class='nx-keyword'>create</span> d1 - -<span class='nx-comment'># Object d1 has instance variables -</span><span class='nx-comment'># x == 1 and y == 2</span></pre></div></div> -<div class="paragraph"><p>Note that the variable definitions are inherited in the same way as -properties. The example in <a href="#xmp-variable">Listing 19</a> shows a -class <code>Derived</code> that inherits from <code>Base</code>. When an instance <code>d1</code> is -created, it will contain the two instance variables <code>x</code> and <code>y</code>. -Note that the variable declarations from <code>property</code> and <code>variable</code> are -used to initialize (and to configure) the instances variables of an object.</p></div> -<div class="paragraph" id="xmp-constructor"><div class="title">Listing 20: Setting Variables in the Constructor</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Base2 { - <span class='nx-comment'># ... -</span> <span class='nx-keyword'>:method</span> <span class='nx-keyword'>init</span> {} { - <span class='nx-keyword'>set</span> :x 1 - <span class='nx-comment'># .... -</span> } -} - -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Derived2 -superclass Base2 { - <span class='nx-comment'># ... -</span> <span class='nx-keyword'>:method</span> <span class='nx-keyword'>init</span> {} { - <span class='nx-keyword'>set</span> :y 2 - <span class='nx-keyword'>next</span> - <span class='nx-comment'># .... -</span> } -} - -<span class='nx-comment'># Create instance of the class Derived2 -</span>Derived2 <span class='nx-keyword'>create</span> d2</pre></div></div> -<div class="paragraph"><p>In many other object oriented languages, the instance variables are -initialized solely by the constructor (similar to class <code>Derived2</code> in -<a href="#xmp-constructor">Listing 20</a>). This approach is certainly -also possible in NX. Note that the approach using constructors -requires an explicit method chaining between the constructors and is -less declarative than the approach in NX using <code>property</code> and <code>variable</code>.</p></div> -<div class="paragraph"><p>Both, <code>property</code> and <code>variable</code> provide much more functionalities. One -can for example declare <code>public</code>, <code>protected</code> or <code>private</code> accessor -methods, or one can define variables to be incremental (for -e.g. adding values to a list of values), or one can define variables -specific behavior.</p></div> -</div> -</div> -<div class="sect2"> -<h3 id="_method_definitions">3.2. Method Definitions</h3> -<div class="paragraph"><p>The basic building blocks of an object oriented program are object and -classes, which contain named pieces of code, the methods.</p></div> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p><strong>Methods</strong> are subroutines (pieces of code) associated with objects -and/or classes. A method has a name, receives optionally arguments -during invocation and returns a value.</p></div> -</div></div> -<div class="paragraph"><p>Plain Tcl provides subroutines, which are not associated with objects -or classes. Tcl distinguishes between +proc+s (scripted subroutines) -and commands (system-languages implemented subroutines).</p></div> -<div class="paragraph"><p>Methods might have different scopes, defining, on which kind of -objects these methods are applicable to. These are described in more -detail later on. For the time being, we deal here with methods defined -on classes, which are applicable for the instance of these classes.</p></div> -<div class="sect3"> -<h4 id="_scripted_methods">3.2.1. Scripted Methods</h4> -<div class="paragraph"><p>Since NX is a scripting language, most methods are most likely -scripted methods, in which the method body contains Tcl code.</p></div> -<div class="paragraph" id="xmp-fido1"><div class="title">Listing 21: Scripted method</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Define a class -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Dog { - - <span class='nx-comment'># Define a scripted method for the class -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bark {} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"[self] Bark, bark, bark."</span> - } -} - -<span class='nx-comment'># Create an instance of the class -</span>Dog <span class='nx-keyword'>create</span> fido - -<span class='nx-comment'># The following line prints "::fido Bark, bark, bark." -</span>fido bark</pre></div></div> -<div class="paragraph"><p>In the example above we create a class <code>Dog</code> with a scripted method -named <code>bark</code>. The method body defines the code, which is executed when -the method is invoked. In this example, the method <code>bar</code> prints out a -line on the terminal starting with the object name (this is determined -by the built in command <code>self</code>) followed by "Bark, bark, bark.". This -method is defined on a class and applicable to instances of the class -(here the instance <code>fido</code>).</p></div> -</div> -<div class="sect3"> -<h4 id="_c_implemented_methods">3.2.2. C-implemented Methods</h4> -<div class="paragraph"><p>Not all of the methods usable in NX are scripted methods; many -predefined methods are defined in the underlying system language, -which is typically C. For example, in <a href="#xmp-fido1">Listing 21</a> we -used the method <code>create</code> to create the class <code>Dog</code> and to create the -dog instance <code>fido</code>. These methods are implemented in C in the next -scripting framework.</p></div> -<div class="paragraph"><p>C-implemented methods are not only provided by the underlying -framework but might be as well defined by application developers. This -is an advanced topic, not covered here. However, application developer -might reuse some generic C code to define their own C-implemented -methods. Such methods are for example <em>accessors</em>, <em>forwarders</em> and -<em>aliases</em>.</p></div> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>An <strong>accessor method</strong> is a method that accesses instance -variables of an object. A call to an accessor -without arguments uses the accessor as a getter, obtaining the actual -value of the associated variable. A call to an accessor with an -argument uses it as a setter, setting the value of the associated -variable.</p></div> -</div></div> -<div class="paragraph"><p>NX provides support for C-implemented accessor methods. Accessors have -already been mentioned in the section about properties. When -the option <code>-accessor public|protected|private</code> is provided to a -<code>variable</code> or <code>property</code> definition, NX creates automatically a -same-named accessors method.</p></div> -<div class="paragraph" id="xmp-fido2"><div class="title">Listing 22: Accessor Methods</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Dog { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bark {} { <span class='nx-keyword'>puts</span> <span class='nx-string'>"[self] Bark, bark, bark."</span> } - <span class='nx-keyword'>:method</span> <span class='nx-keyword'>init</span> {} { Tail <span class='nx-keyword'>create</span> [<span class='nx-keyword'>self</span>]::tail} -} - -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Tail { - <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>public</span> {length:double 5} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> wag {} {<span class='nx-keyword'>return</span> Joy} -} - -<span class='nx-comment'># Create an instance of the class -</span>Dog <span class='nx-keyword'>create</span> fido - -<span class='nx-comment'># Use the accessor "length" as a getter, to obtain the value -</span><span class='nx-comment'># of a property. The following call returns the length of the -</span><span class='nx-comment'># tail of fido -</span>fido::tail length get - -<span class='nx-comment'># Use the accessor "length" as a setter, to alter the value -</span><span class='nx-comment'># of a property. The following call changes the length of -</span><span class='nx-comment'># the tail of fido -</span>fido::tail length <span class='nx-keyword'>set</span> 10 - -<span class='nx-comment'># Proving an invalid values will raise an error -</span>fido::tail length <span class='nx-keyword'>set</span> <span class='nx-string'>"Hello"</span></pre></div></div> -<div class="paragraph"><p><a href="#xmp-fido2">Listing 22</a> shows an extended example, where every dog -has a tail. The object <code>tail</code> is created as a subobject of the dog in -the constructor <code>init</code>. The subobject can be accessed by providing the -full name of the subobject <code>fido::tail</code>. The method <code>length</code> is an -C-implemented accessor, that enforces the value constraint (here a -floating point number, since length uses the value constraint -<code>double</code>). Line 25 will therefore raise an exception, since the -provided values cannot be converted to a double number.</p></div> -<div class="paragraph" id="xmp-fido3"><div class="title">Listing 23: Forwarder Methods</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Dog { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bark {} { <span class='nx-keyword'>puts</span> <span class='nx-string'>"[self] Bark, bark, bark."</span> } - <span class='nx-keyword'>:method</span> <span class='nx-keyword'>init</span> {} { - Tail <span class='nx-keyword'>create</span> [<span class='nx-keyword'>self</span>]::tail - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>forward</span> wag [<span class='nx-keyword'>self</span>]::tail wag - } -} - -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Tail { - <span class='nx-keyword'>:property</span> {length 5} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> wag {} {<span class='nx-keyword'>return</span> Joy} -} - -<span class='nx-comment'># Create an instance of the class -</span>Dog <span class='nx-keyword'>create</span> fido - -<span class='nx-comment'># The invocation of "fido wag" is delegated to "fido::tail wag". -</span><span class='nx-comment'># Therefore, the following method returns "Joy". -</span>fido wag</pre></div></div> -<div class="paragraph"><p><a href="#xmp-fido3">Listing 23</a> again extends the example by adding a -forwarder named <code>wag</code> to the object (e.g. <code>fido</code>). The forwarder -redirects all calls of the form <code>fido wag</code> with arbitrary arguments to -the subobject <code>fido::tail</code>.</p></div> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>A <strong>forwarder method</strong> is a -C-implemented method that redirects an invocation for a certain method -to either a method of another object or to some other method of the -same object. Forwarding an invocation of a method to some other -object is a means of delegation.</p></div> -</div></div> -<div class="paragraph"><p>The functionality of the forwarder can just as well be implemented as -a scripted method, but for the most common cases, the forward -implementation is more efficient, and the <code>forward</code> method expresses -the intention of the developer.</p></div> -<div class="paragraph"><p>The method <code>forwarder</code> has several options to change e.g. the order of -the arguments, or to substitute certain patterns in the argument list -etc. This will be described in later sections.</p></div> -</div> -<div class="sect3"> -<h4 id="_method_aliases">3.2.3. Method-Aliases</h4> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>An <strong>alias method</strong> is a means to register either an existing method, -or a Tcl proc, or a Tcl command as a method with the provided -name on a class or object.</p></div> -</div></div> -<div class="paragraph"><p>In some way, the method alias is a restricted form of a forwarder, -though it does not support delegation to different objects or argument -reordering. The advantage of the method alias compared to a forwarder -is that it has close to zero overhead, especially for aliasing -c-implemented methods.</p></div> -<div class="paragraph" id="xmp-fido4"><div class="title">Listing 24: Method-Alias</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Dog { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bark {} { <span class='nx-keyword'>puts</span> <span class='nx-string'>"[self] Bark, bark, bark."</span> } - - <span class='nx-comment'># Define a public alias for the method "bark" -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>alias</span> warn [<span class='nx-keyword'>:info</span> <span class='nx-keyword'>method</span> handle bark] - <span class='nx-comment'># ... -</span>} - -<span class='nx-comment'># Create an instance of the class -</span>Dog <span class='nx-keyword'>create</span> fido - -<span class='nx-comment'># The following line prints "::fido Bark, bark, bark." -</span>fido warn</pre></div></div> -<div class="paragraph"><p><a href="#xmp-fido4">Listing 24</a> extends the last example by defining an -alias for the method <code>bark</code>. The example only shows the bare -mechanism. In general, method aliases are very powerful means for -reusing pre-existing functionality. The full object system of NX and -XOTcl2 is built from aliases, reusing functionality provided by the -next scripting framework under different names. Method aliases -are as well a means for implementing traits in NX.</p></div> -</div> -</div> -<div class="sect2"> -<h3 id="_method_protection">3.3. Method Protection</h3> -<div class="paragraph"><p>All kinds of methods might have different kind of protections in NX. -The call-protection defines from which calling context methods might -be called. The Next Scripting Framework supports as well redefinition -protection for methods.</p></div> -<div class="paragraph"><p>NX distinguishes between <code>public</code>, <code>protected</code> and <code>private</code> methods, -where the default call-protection is <code>protected</code>.</p></div> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>A <strong>public</strong> method can be called from every context. A <strong>protected</strong> -method can only be invoked from the same object. A <strong>private</strong> method -can only be invoked from methods defined on the same entity -(defined on the same class or on the same object) via the invocation -with the local flag (i.e. "<code>: -local foo</code>").</p></div> -</div></div> -<div class="paragraph"><p>All kind of method protections are applicable for all kind of methods, -either scripted or C-implemented.</p></div> -<div class="paragraph"><p>The distinction between public and protected leads to interfaces for -classes and objects. Public methods are intended for consumers of -these entities. Public methods define the intended ways of providing -methods for external usages (usages, from other objects or -classes). Protected methods are intended for the implementor of the -class or subclasses and not for public usage. The distinction between -protected and public reduces the coupling between consumers and the -implementation, and offers more flexibility to the developer.</p></div> -<div class="paragraph" id="xmp-protected-method"><div class="title">Listing 25: Protected Methods</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Foo { - - <span class='nx-comment'># Define a public method -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { - <span class='nx-comment'># .... -</span> <span class='nx-keyword'>return</span> [:helper] - } - - <span class='nx-comment'># Define a protected method -</span> <span class='nx-keyword'>:method</span> helper {} { - <span class='nx-keyword'>return</span> 1 - } -} - -<span class='nx-comment'># Create an instance of the class: -</span>Foo <span class='nx-keyword'>create</span> f1 - -<span class='nx-comment'># The invocation of the public method "foo" returns 1 -</span>f1 foo - -<span class='nx-comment'># The invocation of the protected method "helper" raises an error: -</span>f1 helper</pre></div></div> -<div class="paragraph"><p>The example above uses <code>:protected method helper …</code>. We could have -used here as well <code>:method helper …</code>, since the default method -call-protection is already protected.</p></div> -<div class="paragraph"><p>The method call-protection of <code>private</code> goes one step further and -helps to hide implementation details also for implementors of -subclasses. Private methods are a means for avoiding unanticipated name -clashes. Consider the following example:</p></div> -<div class="paragraph" id="xmp-private-method"><div class="title">Listing 26: Private Methods</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Base { - <span class='nx-keyword'>:private</span> <span class='nx-keyword'>method</span> helper {a b} {<span class='nx-keyword'>expr</span> {<span class='nx-variable'>$a</span> + <span class='nx-variable'>$b</span>}} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {a b} {: -local helper <span class='nx-variable'>$a</span> <span class='nx-variable'>$b</span>} -} - -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Sub -superclass Base { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bar {a b} {: -local helper <span class='nx-variable'>$a</span> <span class='nx-variable'>$b</span>} - <span class='nx-keyword'>:private</span> <span class='nx-keyword'>method</span> helper {a b} {<span class='nx-keyword'>expr</span> {<span class='nx-variable'>$a</span> * <span class='nx-variable'>$b</span>}} - <span class='nx-keyword'>:create</span> s1 -} - -s1 foo 3 4 ;<span class='nx-comment'># returns 7 -</span>s1 bar 3 4 ;<span class='nx-comment'># returns 12 -</span>s1 helper 3 4 ;<span class='nx-comment'># raises error: unable to dispatch method helper</span></pre></div></div> -<div class="paragraph"><p>The base class implements a public method <code>foo</code> using the helper -method named <code>helper</code>. The derived class implements a as well a public -method <code>bar</code>, which is also using a helper method named <code>helper</code>. When -an instance <code>s1</code> is created from the derived class, the method <code>foo</code> -is invoked which uses in turn the private method of the base -class. Therefore, the invocation <code>s1 foo 3 4</code> returns its sum. If -the <code>local</code> flag had not beed used in helper, <code>s1</code> would -have tried to call the helper of <code>Sub</code>, which would be incorrect. For -all other purposes, the private methods are "invisible" in all -situations, e.g., when mixins are used, or within the <code>next</code>-path, etc.</p></div> -<div class="paragraph"><p>By using the <code>-local</code> flag at the call site it is possible to invoke -only the local definition of the method. If we would call the method -without this flag, the resolution order would be the standard -resolution order, starting with filters, mixins, object methods -and the full intrinsic class hierarchy.</p></div> -<div class="paragraph"><p>NX supports the modifier <code>private</code> for methods and properties. In all -cases <code>private</code> is an instrument to avoid unanticipated interactions -and means actually "accessible for methods defined on the same entity -(object or class)". The main usage for <code>private</code> is to improve -locality of the code e.g. for compositional operations.</p></div> -<div class="paragraph"><p>In order to improve locality for properties, a private property -defines therefore internally a variable with a different name to avoid -unintended interactions. The variable should be accessed via the -private accessor, which can be invoked with the <code>-local</code> flag. In the -following example class <code>D</code> introduces a private property with the -same name as a property in the superclass.</p></div> -<div class="paragraph" id="xmp-private-properties"><div class="title">Listing 27: Private Properties</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># Define a class C with a property "x" and a public accessor -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>public</span> {x c} -} - -<span class='nx-comment'># -</span><span class='nx-comment'># Define a subclass D with a private property "x" -</span><span class='nx-comment'># and a method bar, which is capable of accessing -</span><span class='nx-comment'># the private property. -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> D -superclass C { - <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>private</span> {x d} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bar {p} {<span class='nx-keyword'>return</span> [: -local <span class='nx-variable'>$p</span> get]} -} - -<span class='nx-comment'># -</span><span class='nx-comment'># The private and public (or protected) properties -</span><span class='nx-comment'># define internally separate variable that do not -</span><span class='nx-comment'># conflict. -</span><span class='nx-comment'># -</span>D <span class='nx-keyword'>create</span> d1 -<span class='nx-keyword'>puts</span> [d1 x get] ;<span class='nx-comment'># prints "c" -</span><span class='nx-keyword'>puts</span> [d1 bar x] ;<span class='nx-comment'># prints "d"</span></pre></div></div> -<div class="paragraph"><p>Without the <code>private</code> definition of the property, the definition of -property <code>x</code> in class <code>D</code> would shadow the -definition of the property in the superclass <code>C</code> for its instances -(<code>d1 x</code> or <code>set :x</code> would return <code>d</code> instead of <code>c</code>).</p></div> -</div> -<div class="sect2"> -<h3 id="_applicability_of_methods">3.4. Applicability of Methods</h3> -<div class="paragraph"><p>As defined above, a method is a subroutine defined on an object or -class. This object (or class) contains the method. If the object (or -class) is deleted, the contained methods will be deleted as well.</p></div> -<div class="sect3"> -<h4 id="_instance_methods">3.4.1. Instance Methods</h4> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>Typically, methods are defined on a class, and the methods defined on the -class are applicable to the instances (direct or indirect) of this -class. These methods are called <strong>instance methods</strong>.</p></div> -</div></div> -<div class="paragraph"><p>In the following example method, <code>foo</code> is an instance method defined -on class <code>C</code>.</p></div> -<div class="paragraph" id="xmp-instance-applicable"><div class="title">Listing 28: Methods applicable for instances</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>return</span> 1} - <span class='nx-keyword'>:create</span> c1 -} - -<span class='nx-comment'># Method "foo" is defined on class "C" -</span><span class='nx-comment'># and applicable to the instances of "C" -</span>c1 foo</pre></div></div> -<div class="paragraph"><p>There are many programming languages that only allow these types of methods. -However, NX also allows methods to be defined on objects.</p></div> -</div> -<div class="sect3"> -<h4 id="_object_methods">3.4.2. Object Methods</h4> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>Methods defined on objects are <strong>object methods</strong>. Object -methods are only applicable on the object, on which they are defined. -Object methods cannot be inherited from other objects.</p></div> -</div></div> -<div class="paragraph"><p>The following example defines an object method <code>bar</code> on the -instance <code>c1</code> of class <code>C</code>, and as well as the object specific method -<code>baz</code> defined on the object <code>o1</code>. An object method is defined -via <code>object method</code>.</p></div> -<div class="paragraph"><p>Note that we can define a object method that shadows (redefines) -for this object methods provided from classes.</p></div> -<div class="paragraph" id="xmp-object-applicable1"><div class="title">Listing 29: Object Method</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>return</span> 1} - <span class='nx-keyword'>:create</span> c1 { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>return</span> 2} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {} {<span class='nx-keyword'>return</span> 3} - } -} - -<span class='nx-comment'># Method "bar" is an object specific method of "c1" -</span>c1 bar - -<span class='nx-comment'># object-specific method "foo" returns 2 -</span>c1 foo - -<span class='nx-comment'># Method "baz" is an object specific method of "o1" -</span><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o1 { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> baz {} {<span class='nx-keyword'>return</span> 4} -} -o1 baz</pre></div></div> -</div> -<div class="sect3"> -<h4 id="_class_methods">3.4.3. Class Methods</h4> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>A <strong>class method</strong> is a method defined on a class, which is only -applicable to the class object itself. The class method is actually -an object method of the class object.</p></div> -</div></div> -<div class="paragraph"><p>In NX, all classes are objects. Classes are in NX special kind of -objects that have e.g. the ability to create instances and to provide -methods for the instances. Classes manage their instances. The general -method set for classes is defined on the meta-classes (more about -this later).</p></div> -<div class="paragraph"><p>The following example defines a public class method <code>bar</code> on class -<code>C</code>. The class method is specified by using the modifier <code>object</code> in -front of <code>method</code> in the method definition command.</p></div> -<div class="paragraph" id="xmp-object-applicable2"><div class="title">Listing 30: Class Methods</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-comment'># -</span> <span class='nx-comment'># Define a class method "bar" and an instance -</span> <span class='nx-comment'># method "foo" -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {} {<span class='nx-keyword'>return</span> 2} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>return</span> 1} - - <span class='nx-comment'># -</span> <span class='nx-comment'># Create an instance of the current class -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:create</span> c1 -} - -<span class='nx-comment'># Method "bar" is a class method of class "C" -</span><span class='nx-comment'># therefore applicable on the class object "C" -</span>C bar - -<span class='nx-comment'># Method "foo" is an instance method of "C" -</span><span class='nx-comment'># therefore applicable on instance "c1" -</span>c1 foo - -<span class='nx-comment'># When trying to invoke the class method on the -</span><span class='nx-comment'># instance, an error will be raised. -</span>c1 bar</pre></div></div> -<div class="paragraph"><p>In some other object-oriented programming languages, class methods -are called "static methods".</p></div> -</div> -</div> -<div class="sect2"> -<h3 id="_ensemble_methods">3.5. Ensemble Methods</h3> -<div class="paragraph"><p>NX provides <em>ensemble methods</em> as a means to structure the method name -space and to group related methods. Ensemble methods are similar in -concept to Tcl’s ensemble commands.</p></div> -<div class="exampleblock"> -<div class="content"> -<div class="paragraph"><p>An <strong>ensemble method</strong> is a form of a hierarchical method consisting of -a container method and sub-methods. The first argument of the -container method is interpreted as a selector (the sub-method). Every -sub-method can be an container method as well.</p></div> -</div></div> -<div class="paragraph"><p>Ensemble methods provide a means to group related commands together, -and they are extensible in various ways. It is possible to add -sub-methods at any time to existing ensembles. Furthermore, it is -possible to extend ensemble methods via mixin classes.</p></div> -<div class="paragraph"><p>The following example defines an ensemble method for <code>string</code>. An -ensemble method is defined when the provide method name contains a -space.</p></div> -<div class="paragraph" id="xmp-ensemble-methods"><div class="title">Listing 31: Ensemble Method</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { - - <span class='nx-comment'># Define an ensemble method "string" with sub-methods -</span> <span class='nx-comment'># "length", "tolower" and "info" -</span> - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> <span class='nx-string'>"string length"</span> {x} {....} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> <span class='nx-string'>"string tolower"</span> {x} {...} - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> <span class='nx-string'>"string info"</span> {x} {...} - <span class='nx-comment'>#... -</span> <span class='nx-keyword'>:create</span> c1 -} - -<span class='nx-comment'># Invoke the ensemble method -</span>c1 <span class='nx-keyword'>string</span> length <span class='nx-string'>"hello world"</span></pre></div></div> -</div> -<div class="sect2"> -<h3 id="_method_resolution">3.6. Method Resolution</h3> -<div class="paragraph"><p>When a method is invoked, the applicable method is searched in the -following order:</p></div> -Per-object Mixins -> Per-class Mixins -> Object -> Intrinsic Class Hierarchy -<div class="paragraph"><p>In the case, no mixins are involved, first the object is searched for -an object method with the given name, and then the class hierarchy -of the object. The method can be defined multiple times on the search -path, so some of these method definitions might be <em>shadowed</em> by the -more specific definitions.</p></div> -<div class="paragraph" id="xmp-method-resolution"><div class="title">Listing 32: Method Resolution with Intrinsic Classes</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { - <span class='nx-keyword'>return</span> <span class='nx-string'>"C foo: [next]"</span> - } -} - -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> D -superclass C { - - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { - <span class='nx-keyword'>return</span> <span class='nx-string'>"D foo: [next]"</span> - } - - <span class='nx-keyword'>:create</span> d1 { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {} { - <span class='nx-keyword'>return</span> <span class='nx-string'>"d1 foo: [next]"</span> - } - } -} - -<span class='nx-comment'># Invoke the method foo -</span>d1 foo -<span class='nx-comment'># result: "d1 foo: D foo: C foo: " -</span> -<span class='nx-comment'># Query the precedence order from NX via introspection -</span>d1 <span class='nx-keyword'>info</span> precedence -<span class='nx-comment'># result: "::D ::C ::nx::Object"</span></pre></div></div> -<div class="paragraph"><p>Consider the example in -<a href="#xmp-method-resolution">Listing 32</a>. When the method -<code>foo</code> is invoked on object <code>d1</code>, the object method has the highest -precedence and is therefore invoked. The object methods shadows -the same-named methods in the class hierarchy, namely the method <code>foo</code> -of class <code>D</code> and the method <code>foo</code> of class <code>C</code>. The shadowed methods -can be still invoked, either via the primitive <code>next</code> or via method -handles (we used already method handles in the section about method -aliases). In the example above, <code>next</code> calls the shadowed method and -add their results to the results of every method. So, the final result -contains parts from <code>d1</code>, <code>D</code> and <code>C</code>. Note that the topmost <code>next</code> -in method <code>foo</code> of class <code>C</code> shadows no method <code>foo</code> and simply -returns empty (and not an error message).</p></div> -<div class="paragraph"><p>The introspection method <code>info precedence</code> provides information about -the order, in which classes processed during method resolution.</p></div> -<div class="paragraph" id="xmp-method-resolution2"><div class="title">Listing 33: Method Resolution with Mixin Classes</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> M1 { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { <span class='nx-keyword'>return</span> <span class='nx-string'>"M1 foo: [next]"</span>} -} -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> M2 { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { <span class='nx-keyword'>return</span> <span class='nx-string'>"M2 foo: [next]"</span>} -} - -<span class='nx-comment'># -</span><span class='nx-comment'># "d1" is created based on the definitions of the last example -</span><span class='nx-comment'># -</span><span class='nx-comment'># Add the methods from "M1" as per-object mixin to "d1" -</span>d1 <span class='nx-keyword'>object</span> mixins add M1 - -<span class='nx-comment'># -</span><span class='nx-comment'># Add the methods from "M2" as per-class mixin to class "C" -</span>C mixins add M2 - -<span class='nx-comment'># Invoke the method foo -</span>d1 foo -<span class='nx-comment'># result: "M1 foo: M2 foo: d1 foo: D foo: C foo: " -</span> -<span class='nx-comment'># Query the precedence order from NX via introspection -</span>d1 <span class='nx-keyword'>info</span> precedence -<span class='nx-comment'># result: "::M1 ::M2 ::D ::C ::nx::Object"</span></pre></div></div> -<div class="paragraph"><p>The example in <a href="#xmp-method-resolution2">Listing 33</a> is -an extension of the previous example. We define here two additional -classes <code>M1</code> and <code>M2</code> which are used as per-object and per-class -mixins. Both classes define the method <code>foo</code>, these methods shadow -the definitions of the intrinsic class hierarchy. Therefore an -invocation of <code>foo</code> on object <code>d1</code> causes first an invocation of -method in the per-object mixin.</p></div> -<div class="paragraph" id="xmp-method-resolution3"><div class="title">Listing 34: Method Invocation Flags</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># "d1" is created based on the definitions of the last two examples, -</span><span class='nx-comment'># the mixins "M1" and "M2" are registered. -</span><span class='nx-comment'># -</span><span class='nx-comment'># Define a public object method "bar", which calls the method -</span><span class='nx-comment'># "foo" which various invocation options: -</span><span class='nx-comment'># -</span>d1 <span class='nx-keyword'>public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {} { - <span class='nx-keyword'>puts</span> [:foo] - <span class='nx-keyword'>puts</span> [: -local foo] - <span class='nx-keyword'>puts</span> [: -intrinsic foo] - <span class='nx-keyword'>puts</span> [: -system foo] -} - -<span class='nx-comment'># Invoke the method "bar" -</span>d1 bar</pre></div></div> -<div class="paragraph"><p>In the first line of the body of method <code>bar</code>, the method <code>foo</code> is -called as usual with an implicit receiver, which defaults to the -current object (therefore, the call is equivalent to <code>d1 foo</code>). The -next three calls show how to provide flags that influence the method -resolution. The flags can be provided between the colon and the method -name. These flags are used rather seldom but can be helpful in some -situations.</p></div> -<div class="paragraph"><p>The invocation flag <code>-local</code> means that the method has to be resolved -from the same place, where the current method is defined. Since the -current method is defined as a object method, <code>foo</code> is resolved as -a object method. The effect is that the mixin definitions are -ignored. The invocation flag <code>-local</code> was already introduced int the -section about method protection, where it was used to call <em>private</em> -methods.</p></div> -<div class="paragraph"><p>The invocation flag <code>-intrinsic</code> means that the method has to be resolved -from the intrinsic definitions, meaning simply without mixins. The -effect is here the same as with the invocation flag <code>-local</code>.</p></div> -<div class="paragraph"><p>The invocation flag <code>-system</code> means that the method has to be resolved -from basic - typically predefined - classes of the object system. This -can be useful, when script overloads system methods, but still want to -call the shadowed methods from the base classes. In our case, we have -no definitions of <code>foo</code> on the base clases, therefore an error message -is returned.</p></div> -<div class="paragraph"><p>The output of <a href="#xmp-method-resolution3">Listing 34</a> is:</p></div> -<div class="listingblock"> -<div class="content"> -<pre><code> M1 foo: M2 foo: d1 foo: D foo: C foo: - d1 foo: D foo: C foo: - d1 foo: D foo: C foo: - ::d1: unable to dispatch method 'foo'</code></pre> -</div></div> -</div> -<div class="sect2"> -<h3 id="_parameters">3.7. Parameters</h3> -<div class="paragraph"><p>NX provides a generalized mechanism for passing values to either -methods (we refer to these as <em>method parameters</em>) or to objects -(these are called <em>configure parameters</em>). Both kind of parameters -might have different features, such as:</p></div> -<div class="ulist"><ul> -<li> -<p> -Positional and non-positional parameters -</p> -</li> -<li> -<p> -Required and non-required parameters -</p> -</li> -<li> -<p> -Default values for parameters -</p> -</li> -<li> -<p> -Value-checking for parameters -</p> -</li> -<li> -<p> -Multiplicity of parameters -</p> -</li> -</ul></div> -<div class="paragraph"><p>TODO: complete list above and provide a short summary of the section</p></div> -<div class="paragraph"><p>Before we discuss method and configure parameters in more detail, we -describe the parameter features in the subsequent sections based on -method parameters.</p></div> -<div class="sect3"> -<h4 id="_positional_and_non_positional_parameters">3.7.1. Positional and Non-Positional Parameters</h4> -<div class="paragraph"><p>If the position of a parameter in the list of formal arguments -(e.g. passed to a function) is significant for its meaning, this is a -<em>positional</em> parameter. If the meaning of the parameter is independent -of its position, this is a <em>non-positional</em> parameter. When we call a -method with positional parameters, the meaning of the parameters (the -association with the argument in the argument list of the method) is -determined by its position. When we call a method with non-positional -parameters, their meaning is determined via a name passed with the -argument during invocation.</p></div> -<div class="paragraph" id="xmp-posnonpos"><div class="title">Listing 35: Positional and Non-Positional Method Parameters</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o1 { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Method foo has positional parameters: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {x y} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y=$y"</span> - } - - <span class='nx-comment'># -</span> <span class='nx-comment'># Method bar has non-positional parameters: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {-x -y} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y=$y"</span> - } - - <span class='nx-comment'># -</span> <span class='nx-comment'># Method baz has non-positional and -</span> <span class='nx-comment'># positional parameters: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> baz {-x -y a} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x? [info exists x] y? [info exists y] a=$a"</span> - } -} - -<span class='nx-comment'># invoke foo (positional parameters) -</span>o1 foo 1 2 - -<span class='nx-comment'># invoke bar (non-positional parameters) -</span>o1 bar -y 3 -x 1 -o1 bar -x 1 -y 3 - -<span class='nx-comment'># invoke baz (positional and non-positional parameters) -</span>o1 baz -x 1 100 -o1 baz 200 -o1 baz -- -y</pre></div></div> -<div class="paragraph"><p>Consider the example in <a href="#xmp-posnonpos">Listing 35</a>. The method -<code>foo</code> has the argument list <code>x y</code>. This means that the first argument -is passed in an invocation like <code>o1 foo 1 2</code> to <code>x</code> (here, the value -<code>1</code>), and the second argument is passed to <code>y</code> (here the value <code>2</code>). -Method <code>bar</code> has in contrary just with non-positional arguments. Here -we pass the names of the parameter together with the values. In the -invocation <code>o1 bar -y 3 -x 1</code> the names of the parameters are prefixed -with a dash ("-"). No matter whether in which order we write the -non-positional parameters in the invocation (see line 30 and 31 in -<a href="#xmp-posnonpos">Listing 35</a>) in both cases the variables <code>x</code> -and <code>y</code> in the body of the method <code>bar</code> get the same values assigned -(<code>x</code> becomes <code>1</code>, <code>y</code> becomes <code>3</code>).</p></div> -<div class="paragraph"><p>It is certainly possible to combine positional and non-positional -arguments. Method <code>baz</code> provides two non-positional parameter (<code>-y</code> -and <code>-y</code>) and one positional parameter (namely <code>a</code>). The invocation in -line 34 passes the value of <code>1</code> to <code>x</code> and the value of <code>100</code> to <code>a</code>. -There is no value passed to <code>y</code>, therefore value of <code>y</code> will be -undefined in the body of <code>baz</code>, <code>info exists y</code> checks for the -existence of the variable <code>y</code> and returns <code>0</code>.</p></div> -<div class="paragraph"><p>The invocation in line 35 passes only a value to the positional -parameter. A more tricky case is in line 36, where we want to pass -<code>-y</code> as a value to the positional parameter <code>a</code>. The case is more -tricky since syntactically the argument parser might consider <code>-y</code> as -the name of one of the non-positional parameter. Therefore we use <code>--</code> -(double dash) to indicate the end of the block of the non-positional -parameters and therefore the value of <code>-y</code> is passed to <code>a</code>.</p></div> -</div> -<div class="sect3"> -<h4 id="_optional_and_required_parameters">3.7.2. Optional and Required Parameters</h4> -<div class="paragraph"><p>Per default positional parameters are required, and non-positional -parameters are optional (they can be left out). By using parameter -options, we can as well define positional parameters, which are -optional, and non-positional parameters, which are required.</p></div> -<div class="paragraph" id="xmp-optional-req"><div class="title">Listing 36: Optional and Required Method Parameters</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o2 { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Method foo has one required and one optional -</span> <span class='nx-comment'># positional parameter: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {x:required y:optional} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y? [info exists y]"</span> - } - - <span class='nx-comment'># -</span> <span class='nx-comment'># Method bar has one required and one optional -</span> <span class='nx-comment'># non-positional parameter: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {-x:required -y:optional} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y? [info exists y]"</span> - } -} - -<span class='nx-comment'># invoke foo (one optional positional parameter is missing) -</span>o2 foo 1</pre></div></div> -<div class="paragraph"><p>The example in <a href="#xmp-optional-req">Listing 36</a> defined method <code>foo</code> -with one required and one optional positional parameter. For this -purpose we use the parameter options <code>required</code> and <code>optional</code>. The -parameter options are separated from the parameter name by a colon. If -there are multiple parameter options, these are separated by commas -(we show this in later examples).</p></div> -<div class="paragraph"><p>The parameter definition <code>x:required</code> for method <code>foo</code> is equivalent -to <code>x</code> without any parameter options (see e.g. previous example), -since positional parameters are per default required. The invocation -in line 21 of <a href="#xmp-optional-req">Listing 36</a> will lead to an -undefined variable <code>y</code> in method <code>foo</code>, because no value us passed to -the optional parameter. Note that only trailing positional parameters might be -optional. If we would call method <code>foo</code> of <a href="#xmp-posnonpos">Listing 35</a> with only one argument, the system would raise an -exception.</p></div> -<div class="paragraph"><p>Similarly, we define method <code>bar</code> in <a href="#xmp-optional-req">Listing 36</a> with one required and one optional non-positional -parameter. The parameter definition <code>-y:optional</code> is equivalent to -<code>-y</code>, since non-positional parameter are per default optional. -However, the non-positional parameter <code>-x:required</code> is required. If we -invoke <code>bar</code> without it, the system will raise an exception.</p></div> -</div> -<div class="sect3"> -<h4 id="_default_values_for_parameters">3.7.3. Default Values for Parameters</h4> -<div class="paragraph"><p>Optional parameters might have a default value. This default value is used, -when no argument is provided for the corresponding parameter. Default values can be -specified for positional and non-positional parameters.</p></div> -<div class="paragraph" id="xmp-default-value"><div class="title">Listing 37: Method Parameters with Default Values</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o3 { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Positional parameter with default value: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {{x 1} {y 2}} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y=$y"</span> - } - - <span class='nx-comment'># -</span> <span class='nx-comment'># Non-positional parameter with default value: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {{-x 10} {-y 20}} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y=$y"</span> - } -} - -<span class='nx-comment'># use default values -</span>o3 foo -o3 bar</pre></div></div> -<div class="paragraph"><p>In order to define a default value for a parameter, the parameter -specification must be of the form of a 2 element list, where the -second argument is the default value. See for an example in -<a href="#xmp-default-value">Listing 37</a>.</p></div> -</div> -<div class="sect3"> -<h4 id="_value_constraints">3.7.4. Value Constraints</h4> -<div class="paragraph"><p>NX provides value constraints for all kind of parameters. By -specifying value constraints a developer can restrict the permissible -values for a parameter and document the expected values in the source -code. Value checking in NX is conditional, it can be turned on or off -in general or on a per-usage level (more about this later). The same -mechanisms can be used not only for input value checking, but as well -for return value checking (we will address this point as well later).</p></div> -<div class="sect4"> -<h5 id="_built_in_value_constraints">Built-in Value Constraints</h5> -<div class="paragraph"><p>NX comes with a set of built-in value constraints, which can be -extended on the scripting level. The built-in checkers are either the -native checkers provided directly by the Next Scripting Framework (the -most efficient checkers) or the value checkers provided by Tcl through -<code>string is …</code>. The built-in checkers have as well the advantage that -they can be used also at any time during bootstrap of an object -system, at a time, when e.g. no objects or methods are defined. The -same checkers are used as well for all C-implemented primitives of NX -and the Next Scripting Framework.</p></div> -<div class="imageblock" id="img-value-checkers" style="text-align:center;"> -<div class="content"> -<img src="value-checkers.png" alt="value-checkers.png" /> -</div> -<div class="title">Figure 38. General Applicable Value Checkers in NX</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p><a href="#img-value-checkers">Figure 38</a> shows the built-in -general applicable value checkers available in NX, which can be used -for all method and configure parameters. In the next step, we show how to -use these value-checkers for checking permissible values for method -parameters. Then we will show, how to provide more detailed value -constraints.</p></div> -<div class="paragraph" id="xmp-value-check"><div class="title">Listing 39: Method Parameters with Value Constraints</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o4 { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Positional parameter with value constraints: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {x:integer o<span class='nx-keyword'>:object</span>,optional} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x o? [info exists o]"</span> - } - - <span class='nx-comment'># -</span> <span class='nx-comment'># Non-positional parameter with value constraints: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {{-x:integer 10} {-verbose:boolean false}} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x verbose=$verbose"</span> - } -} - -<span class='nx-comment'># The following invocation raises an exception, since the -</span><span class='nx-comment'># value "a" for parameter "x" is not an integer -</span>o4 foo a</pre></div></div> -<div class="paragraph"><p>Value constraints are specified as parameter options in the parameter -specifications. The parameter specification <code>x:integer</code> defines <code>x</code> as -a required positional parameter which value is constraint to an -integer. The parameter specification <code>o:object,optional</code> shows how to -combine multiple parameter options. The parameter <code>o</code> is an optional -positional parameter, its value must be an object (see -<a href="#xmp-value-check">Listing 39</a>). Value constraints are -specified exactly the same way for non-positional parameters (see -method <code>bar</code> in <a href="#xmp-value-check">Listing 39</a>).</p></div> -<div class="paragraph" id="xmp-check-parameterized"><div class="title">Listing 40: Parameterized Value Constraints</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># Create classes for Person and Project -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Person -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Project - -<span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o5 { - <span class='nx-comment'># -</span> <span class='nx-comment'># Parameterized value constraints -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> work { - -person<span class='nx-keyword'>:object</span>,type=Person - -project<span class='nx-keyword'>:object</span>,type=Project - } { - <span class='nx-comment'># ... -</span> } -} - -<span class='nx-comment'># -</span><span class='nx-comment'># Create a Person and a Project instance -</span><span class='nx-comment'># -</span>Person <span class='nx-keyword'>create</span> gustaf -Project <span class='nx-keyword'>create</span> nx - -<span class='nx-comment'># -</span><span class='nx-comment'># Use method with value constraints -</span><span class='nx-comment'># -</span>o5 work -person gustaf -project nx</pre></div></div> -<div class="paragraph"><p>The native checkers <code>object</code>, <code>class</code>, <code>metaclass</code> and <code>baseclass</code> can -be further specialized with the parameter option <code>type</code> to restrict -the permissible values to instances of certain classes. We can use for -example the native value constraint <code>object</code> either for testing -whether an argument is some object (without further constraints, as in -<a href="#xmp-default-value">Listing 37</a>, method <code>foo</code>), or we can -constrain the value further to some type (direct or indirect instance -of a class). This is shown by method <code>work</code> in -<a href="#xmp-check-parameterized">Listing 40</a> which requires -the parameter <code>-person</code> to be an instance of class <code>Person</code> and the -parameter <code>-project</code> to be an instance of class <code>Project</code>.</p></div> -</div> -<div class="sect4"> -<h5 id="_scripted_value_constraints">Scripted Value Constraints</h5> -<div class="paragraph"><p>The set of predefined value checkers can be extended by application -programs via defining methods following certain conventions. The user -defined value checkers are defined as methods of the class <code>nx::Slot</code> -or of one of its subclasses or instances. We will address such cases -in the next sections. In the following example we define two new -value checkers on class <code>nx::Slot</code>. The first value checker is called -<code>groupsize</code>, the second one is called <code>choice</code>.</p></div> -<div class="paragraph" id="xmp-user-types"><div class="title">Listing 41: Scripted Value Checker for Method Parameters</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># Value checker named "groupsize" -</span><span class='nx-comment'># -</span>::nx::Slot <span class='nx-keyword'>method</span> type=groupsize {name value} { - <span class='nx-keyword'>if</span> {<span class='nx-variable'>$value</span> < 1 || <span class='nx-variable'>$value</span> > 6} { - <span class='nx-keyword'>error</span> <span class='nx-string'>"Value '$value' of parameter $name is not between 1 and 6"</span> - } -} - -<span class='nx-comment'># -</span><span class='nx-comment'># Value checker named "choice" with extra argument -</span><span class='nx-comment'># -</span>::nx::Slot <span class='nx-keyword'>method</span> type=choice {name value arg} { - <span class='nx-keyword'>if</span> {<span class='nx-variable'>$value</span> ni [<span class='nx-keyword'>split</span> <span class='nx-variable'>$arg</span> |]} { - <span class='nx-keyword'>error</span> <span class='nx-string'>"Value '$value' of parameter $name not in permissible values $arg"</span> - } -} - -<span class='nx-comment'># -</span><span class='nx-comment'># Create an application class D -</span><span class='nx-comment'># using the new value checkers -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> D { - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {a:groupsize} { - <span class='nx-comment'># ... -</span> } - <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bar {a:choice,arg=red|yellow|green b:choice,arg=good|bad} { - <span class='nx-comment'># ... -</span> } -} - -D <span class='nx-keyword'>create</span> d1 - -<span class='nx-comment'># testing "groupsize"; -</span><span class='nx-comment'># the second call (with value 10) will raise an exception: -</span>d1 foo 2 -d1 foo 10 - -<span class='nx-comment'># testing "choice" -</span><span class='nx-comment'># the second call (with value pink for parameter a) -</span><span class='nx-comment'># will raise an exception: -</span>d1 bar green good -d1 bar pink bad</pre></div></div> -<div class="paragraph"><p>In order to define a checker <code>groupsize</code> a method of the name -<code>type=groupsize</code> is defined. This method receives two arguments, -<code>name</code> and <code>value</code>. The first argument is the name of the parameter -(mostly used for the error message) and the second parameter is -provided value. The value checker simply tests whether the provided -value is between 1 and 3 and raises an exception if this is not the -case (invocation in line 36 in <a href="#xmp-user-types">Listing 41</a>).</p></div> -<div class="paragraph"><p>The checker <code>groupsize</code> has the permissible values defined in its -method’s body. It is as well possible to define more generic checkers -that can be parameterized. For this parameterization, one can pass an -argument to the checker method (last argument). The checker <code>choice</code> -can be used for restricting the values to a set of predefined -constants. This set is defined in the parameter specification. The -parameter <code>a</code> of method <code>bar</code> in <a href="#xmp-user-types">Listing 41</a> -is restricted to the values <code>red</code>, <code>yellow</code> or <code>green</code>, and the -parameter <code>b</code> is restricted to <code>good</code> or <code>bad</code>. Note that the syntax -of the permissible values is solely defined by the definition of the -value checker in lines 13 to 17. The invocation in line 39 will be ok, -the invocation in line 40 will raise an exception, since <code>pink</code> is not -allowed.</p></div> -<div class="paragraph"><p>If the same checks are used in many places in the program, -defining names for the value checker will be the better choice since -it improves maintainability. For seldom used kind of checks, the -parameterized value checkers might be more convenient.</p></div> -</div> -</div> -<div class="sect3"> -<h4 id="_multiplicity">3.7.5. Multiplicity</h4> -<div class="sidebarblock"> -<div class="content"> -<div class="paragraph"><p><strong>Multiplicity</strong> is used to define whether a parameter should receive -single or multiple values.</p></div> -</div></div> -<div class="paragraph"><p>A multiplicity specification has a lower and an upper bound. A lower -bound of <code>0</code> means that the value might be empty. A lower bound of <code>1</code> -means that the parameter needs at least one value. The upper bound -might be <code>1</code> or <code>n</code> (or synonymously <code>*</code>). While the upper bound of -<code>1</code> states that at most one value has to be passed, the upper bound of -<code>n</code> says that multiple values are permitted. Other kinds of -multiplicity are currently not allowed.</p></div> -<div class="paragraph"><p>The multiplicity is written as parameter option in the parameter -specification in the form <em>lower-bound</em>..<em>upper-bound</em>. If no -multiplicity is defined the default multiplicity is <code>1..1</code>, which -means: provide exactly one (atomic) value (this was the case in the -previous examples).</p></div> -<div class="paragraph" id="xmp-multiplicity"><div class="title">Listing 42: Method Parameters with Explicit Multiplicity</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o6 { - - <span class='nx-comment'># -</span> <span class='nx-comment'># Positional parameter with an possibly empty -</span> <span class='nx-comment'># single value -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {x:integer,0..1} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x"</span> - } - - <span class='nx-comment'># -</span> <span class='nx-comment'># Positional parameter with an possibly empty -</span> <span class='nx-comment'># list of values value -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {x:integer,0..n} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x"</span> - } - - <span class='nx-comment'># -</span> <span class='nx-comment'># Positional parameter with a non-empty -</span> <span class='nx-comment'># list of values -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> baz {x:integer,1..n} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x"</span> - } -}</pre></div></div> -<div class="paragraph"><p><a href="#xmp-multiplicity">Listing 42</a> contains three examples for -positional parameters with different multiplicities. Multiplicity is -often combined with value constraints. A parameter specification of -the form <code>x:integer,0..n</code> means that the parameter <code>x</code> receives a list -of integers, which might be empty. Note that the value constraints are -applied to every single element of the list.</p></div> -<div class="paragraph"><p>The parameter specification <code>x:integer,0..1</code> means that <code>x</code> might be -an integer or it might be empty. This is one style of specifying that -no explicit value is passed for a certain parameter. Another style is -to use required or optional parameters. NX does not enforce any -particular style for handling unspecified values.</p></div> -<div class="paragraph"><p>All the examples in <a href="#xmp-multiplicity">Listing 42</a> are for -single positional parameters. Certainly, multiplicity is fully -orthogonal with the other parameter features and can be used as well -for multiple parameters, non-positional parameter, default values, -etc.</p></div> -</div> -<div class="sect3"> -<h4 id="_defaults_substitution">3.7.6. Defaults substitution</h4> -<div class="paragraph"><p>Optional object and method parameters can set a default value. Recall -that default values can be specified for positional and non-positional -parameters, alike. This default value is used to define a -corresponding method-local and object variable, respectively, and to -set it to the default value. By default, the default value is taken -literally (without any substitutions). Default values can also be -preprocessed into a final value using Tcl substitution as provided by -the Tcl <code>[subst]</code> command. To control the kind of substitutions to be -performed, the parameter option <code>substdefault</code> can be provided.</p></div> -<div class="paragraph" id="substdefault"><div class="title">Listing 43: Default-value substitution using <code>substdefault</code></div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> ::D -<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> ::C { - <span class='nx-comment'># -</span> <span class='nx-comment'># By default all substitutions (command, variable, control -</span> <span class='nx-comment'># characters) are active, when "substdefault" is used: -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:property</span> {d<span class='nx-keyword'>:object</span>,type=::D,substdefault {[::D <span class='nx-keyword'>new</span>]}} - - <span class='nx-comment'># -</span> <span class='nx-comment'># The actual property values are computed and -</span> <span class='nx-comment'># set at instantiation time. -</span> <span class='nx-comment'># -</span> <span class='nx-keyword'>:create</span> ::c -} - -::c <span class='nx-keyword'>cget</span> -d</pre></div></div> -<div class="paragraph"><p><a href="#substdefault">Listing 43</a> uses <code>substdefault</code> -to provide a default value for the property <code>d</code>. In this example, the -default value is a fresh instance of -class <code>::D</code>. When the parameter option <code>substdefault</code> is used -default, all substitution kinds of Tcl are active: command, variable, and -backslash substitution. <code>substdefault</code> can be -parametrized to include or to exclude any combination of substitution -kinds by providing a bitmask:</p></div> -<div class="ulist"><ul> -<li> -<p> -<code>substdefault=0b111</code>: all substitutions active (default) -</p> -</li> -<li> -<p> -<code>substdefault=0b100</code>: substitute backslashes only (like <code>subst -novariables -nocommands</code>) -</p> -</li> -<li> -<p> -<code>substdefault=0b010</code>: substitute variables only (like <code>subst -nobackslashes -nocommands</code>) -</p> -</li> -<li> -<p> -<code>substdefault=0b001</code>: substitute commands only (like <code>subst -nobackslashes -novariables</code>) -</p> -</li> -<li> -<p> -<code>substdefault=0b000</code>: substitute nothing (like <code>subst -nobackslashes -nocommands -novariables</code>, noop) -</p> -</li> -</ul></div> -</div> -</div> -</div> -</div> -<div class="sect1"> -<h2 id="_advanced_language_features">4. Advanced Language Features</h2> -<div class="sectionbody"> -<div class="paragraph"><p>…</p></div> -<div class="sect2"> -<h3 id="_objects_classes_and_meta_classes">4.1. Objects, Classes and Meta-Classes</h3> -<div class="paragraph"><p>…</p></div> -</div> -<div class="sect2"> -<h3 id="_resolution_order_and_next_path">4.2. Resolution Order and Next-Path</h3> -<div class="paragraph"><p>…</p></div> -</div> -<div class="sect2"> -<h3 id="_details_on_method_and_configure_parameters">4.3. Details on Method and Configure Parameters</h3> -<div class="paragraph"><p>The parameter specifications are used in NX for the following -purposes. They are used for</p></div> -<div class="ulist"><ul> -<li> -<p> -the specification of input arguments of methods and commands, for -</p> -</li> -<li> -<p> -the specification of return values of methods and commands, and for -</p> -</li> -<li> -<p> -the specification for the initialization of objects. -</p> -</li> -</ul></div> -<div class="paragraph"><p>We refer to the first two as method parameters and the last one as -configure parameters. The examples in the previous sections all parameter -specification were specifications of method parameters.</p></div> -<div class="sidebarblock"> -<div class="content"> -<div class="paragraph"><p><strong>Method parameters</strong> specify properties about permissible values passed -to methods.</p></div> -</div></div> -<div class="paragraph"><p>The method parameter specify how methods are invoked, how the -actual arguments are passed to local variables of the invoked method -and what kind of checks should be performed on these.</p></div> -<div class="sidebarblock"> -<div class="content"> -<div class="paragraph"><p><strong>Configure parameters</strong> are parameters that specify, how objects -can be parameterized upon creation.</p></div> -</div></div> -<div class="paragraph"><p>Syntactically, configure parameters and method parameters are the same, -although there are certain differences (e.g. some parameter options -are only applicable for objects parameters, the list of object -parameters is computed dynamically from the class structures, object -parameters are often used in combination with special setter methods, -etc.). Consider the following example, where we define the two -application classes <code>Person</code> and <code>Student</code> with a few properties.</p></div> -<div class="paragraph" id="xmp-object-parameters"><div class="title">Listing 44: Configure Parameters</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># -</span><span class='nx-comment'># Define a class Person with properties "name" -</span><span class='nx-comment'># and "birthday" -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Person { - <span class='nx-keyword'>:property</span> name:required - <span class='nx-keyword'>:property</span> birthday -} - -<span class='nx-comment'># -</span><span class='nx-comment'># Define a class Student as specialization of Person -</span><span class='nx-comment'># with and additional property -</span><span class='nx-comment'># -</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Student -superclass Person { - <span class='nx-keyword'>:property</span> matnr:required - <span class='nx-keyword'>:property</span> {oncampus:boolean true} -} - -<span class='nx-comment'># -</span><span class='nx-comment'># Create instances using configure parameters -</span><span class='nx-comment'># for the initialization -</span><span class='nx-comment'># -</span>Person <span class='nx-keyword'>create</span> p1 -name Bob -Student <span class='nx-keyword'>create</span> s1 -name Susan -matnr 4711 - -<span class='nx-comment'># Access property value via "cget" method -</span><span class='nx-keyword'>puts</span> <span class='nx-string'>"The name of s1 is [s1 cget -name]"</span></pre></div></div> -<div class="paragraph"><p>The class <code>Person</code> has two properties <code>name</code> and <code>birthday</code>, where the -property <code>name</code> is required, the property <code>birthday</code> is not. The -class <code>Student</code> is a subclass of <code>Person</code> with the additional required -property <code>matnr</code> and an optional property <code>oncampus</code> with the -default value <code>true</code> (see <a href="#xmp-object-parameters">Listing 44</a>). The class diagram below visualizes these -definitions.</p></div> -<div class="imageblock" id="img-configure-parameters" style="text-align:center;"> -<div class="content"> -<img src="configure-parameter.png" alt="configure-parameter.png" /> -</div> -<div class="title">Figure 45. System and Application Classes</div> -</div> -<div class="paragraph"><p></p></div> -<div class="paragraph"><p>In NX, these definitions imply that instances of the class of <code>Person</code> -have the properties <code>name</code> and <code>birthday</code> as <em>non-positional object -parameters</em>. Furthermore it implies that instances of <code>Student</code> will -have the configure parameters of <code>Person</code> augmented with the object -parameters from <code>Student</code> (namely <code>matnr</code> and <code>oncampus</code>). Based on -these configure parameters, we can create a <code>Person</code> named <code>Bob</code> and a -<code>Student</code> named <code>Susan</code> with the matriculation number <code>4711</code> (see line -23 and 24 in <<xmp-object-parameters, -instance variables <code>name</code>, <code>matnr</code> and <code>oncampus</code> (the latter is -initialized with the default value).</p></div> -<div class="sect3"> -<h4 id="_configure_parameters_available_for_all_nx_objects">4.3.1. Configure Parameters available for all NX Objects</h4> -<div class="paragraph"><p>The configure parameters are not limited to the application defined -properties, also NX provides some predefined definitions. Since -<code>Person</code> is a subclass of <code>nx::Object</code> also the configure parameters of -<code>nx::Object</code> are inherited. In the introductory stack example, we used -<code>-mixins</code> applied to an object to denote per-object mixins (see -<a href="#xmp-using-class-safety">Listing 8</a>). Since <code>mixins</code> -is defined as a parameter on <code>nx::Object</code> it can be used as an object -parameter <code>-mixins</code> for all objects in NX. To put it in other words, -every object can be configured to have per-object mixins. If we would -remove this definition, this feature would be removed as well.</p></div> -<div class="paragraph"><p>As shown in the introductory examples, every object can be configured -via a scripted initialization block (the optional scripted block -specified at object creation as last argument; see -<a href="#xmp-object-stack">Listing 5</a> or -<a href="#xmp-object-integer-stack">Listing 12</a>). The -scripted block and its meaning are as well defined by the means of -configure parameters. However, this configure parameter is positional (last -argument) and optional (it can be omitted). The following listing shows -the configure parameters of <code>Person p1</code> and <code>Student s1</code>.</p></div> -<div class="paragraph" id="xmp-object-parameter-list"><div class="title">Listing 46: Computed Actual Configure Parameter</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>Configure parameters <span class='nx-keyword'>for</span> Person p1: - Command: - p1 <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>configure</span> - Result: - -name <span class='nx-placeholder'>/value/</span> ?-birthday <span class='nx-placeholder'>/value/</span>? ?-object-mixins /mixinreg .../<span class='nx-placeholder'>? - ?</span>-class /<span class='nx-keyword'>class</span>/? ?-object-filters /filterreg .../? ?/__initblock/? - -Configure parameter <span class='nx-keyword'>for</span> Student s1: - Command: - s1 <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>configure</span> - Result: - ?-oncampus <span class='nx-placeholder'>/boolean/</span>? -matnr <span class='nx-placeholder'>/value/</span> -name <span class='nx-placeholder'>/value/</span> - ?-birthday <span class='nx-placeholder'>/value/</span>? ?-object-mixins /mixinreg .../? ?-class /<span class='nx-keyword'>class</span>/<span class='nx-placeholder'>? - ?</span>-object-filters /filterreg .../? ?/__initblock/?</pre></div></div> -<div class="paragraph"><p>The given parameter show, how (a) objects can be configured -at runtime or (b) how new instances can be configured -at creation time via the <code>new</code> or <code>create</code> methods. -Introspection can be used to obtain the configuration -parameters from an object via -<code>p1 info lookup parameters configure</code> -(returning the configure parameters currently applicable for -<code>configure</code> or <code>cget</code>) or from a class -<code>Person info lookup parameters create</code> on a class -(returning the configure parameters applicable when an object -of this class is created)</p></div> -<div class="paragraph"><p>The listed configure parameter types <code>mixinreg</code> and -<code>filterreg</code> are for converting definitions of filters and mixins. The -last value <code>__initblock</code> says that the content of this variable -will be executed in the context of the object being created (before -the constructor <code>init</code> is called). More about the configure parameter -types later.</p></div> -</div> -<div class="sect3"> -<h4 id="_configure_parameters_available_for_all_nx_classes">4.3.2. Configure Parameters available for all NX Classes</h4> -<div class="paragraph"><p>Since classes are certain kind of objects, classes are parameterized -in the same way as objects. A typical parameter for a class definition -is the relation of the class to its superclass.In our example, we have -specified, that <code>Student</code> has <code>Person</code> as superclass via the -non-positional configure parameter <code>-superclass</code>. If no superclass is -specified for a class, the default superclass is -<code>nx::Object</code>. Therefore <code>nx::Object</code> is the default value for the -parameter <code>superclass</code>.</p></div> -<div class="paragraph"><p>Another frequently used parameter for classes is <code>-mixins</code> to denote -per-class mixins (see e.g. the introductory Stack example in -<a href="#xmp-class-safestack">Listing 10</a>), which is defined in -the same way.</p></div> -<div class="paragraph"><p>Since <code>Student</code> is an instance of the meta-class <code>nx::Class</code> it -inherits the configure parameters from <code>nx::Class</code> (see class diagram -<a href="#img-configure-parameters">Figure 45</a>). -Therefore, one can use e.g. <code>-superclass</code> in the definition of classes.</p></div> -<div class="paragraph"><p>Since <code>nx::Class</code> is a subclass of <code>nx::Object</code>, the meta-class -<code>nx::Class</code> inherits the parameter definitions from the most general -class <code>nx::Object</code>. Therefore, every class might as well be configured -with a scripted initialization block the same way as objects can be -configured. We used actually this scripted initialization block in -most examples for defining the methods of the class. The following -listing shows (simplified) the parameters applicable for <code>Class -Student</code>.</p></div> -<div class="paragraph" id="xmp-class-parameter-list"><div class="title">Listing 47: Parameters for Classes</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>Configure parameter <span class='nx-keyword'>for</span> <span class='nx-keyword'>class</span> <span class='nx-keyword'>nx::Class</span> - Command: - <span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>configure</span> - Result: - ?-superclass /<span class='nx-keyword'>class</span> .../? ?-mixins /mixinreg .../<span class='nx-placeholder'>? - ?</span>-filters /filterreg .../? ?-object-mixins /mixinreg .../<span class='nx-placeholder'>? - ?</span>-class /<span class='nx-keyword'>class</span>/? ?-object-filters /filterreg .../? ?/__initblock/?</pre></div></div> -</div> -<div class="sect3"> -<h4 id="_user_defined_parameter_types">4.3.3. User defined Parameter Types</h4> -<div class="paragraph"><p>More detailed definition of the configure parameter types comes here.</p></div> -</div> -<div class="sect3"> -<h4 id="_slot_classes_and_slot_objects">4.3.4. Slot Classes and Slot Objects</h4> -<div class="paragraph"><p>In one of the previous sections, we defined scripted (application -defined) checker methods on a class named <code>nx::Slot</code>. In general NX -offers the possibility to define value checkers not only for all -usages of parameters but as well differently for method parameters or -configure parameters</p></div> -<div class="imageblock" id="img-slots" style="text-align:center;"> -<div class="content"> -<img src="slots.png" alt="slots.png" /> -</div> -<div class="title">Figure 48. Slot Classes and Objects</div> -</div> -<div class="paragraph"><p></p></div> -</div> -<div class="sect3"> -<h4 id="_attribute_slots">4.3.5. Attribute Slots</h4> -<div class="paragraph"><p>Still Missing</p></div> -<div class="ulist"><ul> -<li> -<p> -return value checking -</p> -</li> -<li> -<p> -switch -</p> -</li> -<li> -<p> -initcmd … -</p> -</li> -<li> -<p> -subst rules -</p> -</li> -<li> -<p> -converter -</p> -</li> -<li> -<p> -incremental slots -</p> -</li> -</ul></div> -</div> -</div> -</div> -</div> -<div class="sect1"> -<h2 id="_miscellaneous">5. Miscellaneous</h2> -<div class="sectionbody"> -<div class="paragraph"><p>…</p></div> -<div class="sect2"> -<h3 id="_profiling">5.1. Profiling</h3> -<div class="paragraph"><p>…</p></div> -</div> -<div class="sect2"> -<h3 id="_unknown_handlers">5.2. Unknown Handlers</h3> -<div class="paragraph"><p>NX provides two kinds of unknown handlers:</p></div> -<div class="ulist"><ul> -<li> -<p> -Unknown handlers for methods -</p> -</li> -<li> -<p> -Unknown handlers for objects and classes -</p> -</li> -</ul></div> -<div class="sect3"> -<h4 id="_unknown_handlers_for_methods">5.2.1. Unknown Handlers for Methods</h4> -<div class="paragraph"><p>Object and classes might be equipped -with a method <code>unknown</code> which is called in cases, where an unknown -method is called. The method unknown receives as first argument the -called method followed by the provided arguments</p></div> -<div class="paragraph" id="xmp-unknown-method"><div class="title">Listing 49: Unknown Method Handler</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nx::Object <span class='nx-keyword'>create</span> o { - <span class='nx-keyword'>:object</span> <span class='nx-keyword'>method</span> <span class='nx-keyword'>unknown</span> {called_method args} { - <span class='nx-keyword'>puts</span> <span class='nx-string'>"Unknown method '$called_method' called"</span> - } -} - -<span class='nx-comment'># Invoke an unknown method for object o: -</span>o foo 1 2 3 - -<span class='nx-comment'># Output will be: "Unknown method 'foo' called"</span></pre></div></div> -<div class="paragraph"><p>Without any provision of an unknown method handler, an error will be -raised, when an unknown method is called.</p></div> -</div> -<div class="sect3"> -<h4 id="_unknown_handlers_for_objects_and_classes">5.2.2. Unknown Handlers for Objects and Classes</h4> -<div class="paragraph"><p>The next scripting framework provides in addition to unknown method -handlers also a means to dynamically create objects and classes, when -these are referenced. This happens e.g. when superclasses, mixins, or -parent objects are referenced. This mechanism can be used to implement -e.g. lazy loading of these classes. Nsf allows one to register multiple -unknown handlers, each identified by a key (a unique name, different -from the keys of other unknown handlers).</p></div> -<div class="paragraph" id="xmp-unknown-class"><div class="title">Listing 50: Unknown Class Handler</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'>::nx::Class <span class='nx-keyword'>public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> __unknown {name} { - <span class='nx-comment'># A very simple unknown handler, showing just how -</span> <span class='nx-comment'># the mechanism works. -</span> <span class='nx-keyword'>puts</span> <span class='nx-string'>"***** __unknown called with <$name>"</span> - ::nx::Class <span class='nx-keyword'>create</span> <span class='nx-variable'>$name</span> -} - -<span class='nx-comment'># Register an unknown handler as a method of ::nx::Class -</span>::nsf::object::unknown::add nx {::nx::Class __unknown} - -::nx::Object <span class='nx-keyword'>create</span> o { - <span class='nx-comment'># The class M is unknown at this point -</span> - <span class='nx-keyword'>:object</span> mixins add M - <span class='nx-comment'># The line above has triggered the unknown class handler, -</span> <span class='nx-comment'># class M is now defined -</span> - <span class='nx-keyword'>puts</span> [<span class='nx-keyword'>:info</span> <span class='nx-keyword'>object</span> mixins] - <span class='nx-comment'># The output will be: -</span> <span class='nx-comment'># ***** __unknown called with <::M> -</span> <span class='nx-comment'># ::M -</span>}</pre></div></div> -<div class="paragraph"><p>The Next Scripting Framework allows one to add, query, delete and list unknown handlers.</p></div> -<div class="paragraph" id="xmp-unknown-registration"><div class="title">Listing 51: Unknown Handler registration</div><p></p></div> -<div class="listingblock"> -<div class="content"><style type='text/css'> -.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} -table.nx {border-collapse: collapse; border-spacing: 3px;} -.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} -.nx-string {color: #779977; font-weight: normal; font-style: italic;} -.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} -.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} -.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} -.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} -</style> -<pre class='nx'><span class='nx-comment'># Interface for unknown handlers: -</span><span class='nx-comment'># nsf::object::unknown::add /key/ /handler/ -</span><span class='nx-comment'># nsf::object::unknown::get /key/ -</span><span class='nx-comment'># nsf::object::unknown::delete /key/ -</span><span class='nx-comment'># nsf::object::unknown::keys</span></pre></div></div> -<div class="ulist bibliography"><div class="title">References</div><ul> -<li> -<p> -<a id="Zdun"></a> U. Zdun, M. Strembeck, G. Neumann: - Object-Based and Class-Based Composition of Transitive Mixins, - Information and Software Technology, 49(8) 2007 . -</p> -</li> -<li> -<p> -<a id="Neumann and Zdun 1999a"></a> G. Neumann and U. Zdun: Filters as a - language support for design patterns in object-oriented scripting - languages. In Proceedings of COOTS’99, 5th Conference on - Object-Oriented Technologies and Systems, San Diego, May 1999. -</p> -</li> -<li> -<p> -<a id="Neumann and Zdun 1999b"></a> G. Neumann and U. Zdun: Implementing - object-specific design patterns using per-object mixins. In Proc. of - NOSA`99, Second Nordic Workshop on Software Architecture, Ronneby, - Sweden, August 1999. -</p> -</li> -<li> -<p> -<a id="Neumann and Zdun 1999c"></a> G. Neumann and U. Zdun: Enhancing - object-based system composition through per-object mixins. In - Proceedings of Asia-Pacific Software Engineering Conference (APSEC), - Takamatsu, Japan, December 1999. -</p> -</li> -<li> -<p> -<a id="Neumann and Zdun 2000a"></a> G. Neumann and U. Zdun: XOTCL, an - object-oriented scripting language. In Proceedings of Tcl2k: The - 7th USENIX Tcl/Tk Conference, Austin, Texas, February 2000. -</p> -</li> -<li> -<p> -<a id="Neumann and Zdun 2000b"></a> G. Neumann and U. Zdun: Towards the Usage - of Dynamic Object Aggregations as a Form of Composition In: - Proceedings of Symposium of Applied Computing (SAC’00), Como, - Italy, Mar 19-21, 2000. -</p> -</li> -<li> -<p> -<a id="Neumann and Sobernig 2009"></a> G. Neumann, S. Sobernig: XOTcl 2.0 - A - Ten-Year Retrospective and Outlook, in: Proceedings of the Sixteenth - Annual Tcl/Tk Conference, Portland, Oregon, October, 2009. -</p> -</li> -<li> -<p> -<a id="Ousterhout 1990"></a> J. K. Ousterhout: Tcl: An embeddable command - language. In Proc. of the 1990 Winter USENIX Conference, January 1990. -</p> -</li> -<li> -<p> -<a id="Ousterhout 1998"></a> J. K. Ousterhout: Scripting: Higher Level - Programming for the 21st Century, IEEE Computer 31(3), March 1998. -</p> -</li> -<li> -<p> -<a id="Wetherall and Lindblad 1995"></a> D. Wetherall and C. J. Lindblad: Extending Tcl for - Dynamic Object-Oriented Programming. Proc. of the Tcl/Tk Workshop '95, - July 1995. -</p> -</li> -</ul></div> -</div> -</div> -</div> -</div> -</div> -<div id="footnotes"><hr /></div> -<div id="footer"> -<div id="footer-text"> -Version 2.2.0<br /> -Last updated 2019-04-12 16:25:08 CEST -</div> -</div> -</body> -</html> +</div> +</div> +<div id="content"> +<div id="preamble"> +<div class="sectionbody"> +<div class="sidebarblock"> +<div class="content"> +<div class="title">Abstract</div> +<div class="paragraph"><p>This document provides a tutorial for the Next Scripting +Language NX.</p></div> +</div></div> +<div class="paragraph"><p>The Next Scripting Language (NX) is a highly flexible object oriented +scripting language based on Tcl <a href="#Ousterhout 1990">[Ousterhout 1990]</a>. NX is a successor +of XOTcl 1 <a href="#Neumann and Zdun 2000a">[Neumann and Zdun 2000a]</a> and was developed based on 10 +years of experience with XOTcl in projects containing several hundred +thousand lines of code. While XOTcl was the first language designed to +provide <em>language support for design patterns</em>, the focus of the Next +Scripting Framework and NX is on combining this with <em>Language +Oriented Programming</em>. In many respects, NX was designed to ease the +learning of the language for novices (by using a more mainstream +terminology, higher orthogonality of the methods, less predefined +methods), to improve maintainability (remove sources of common errors) +and to encourage developers to write better structured programs (to +provide interfaces) especially for large projects, where many +developers are involved.</p></div> +<div class="paragraph"><p>The Next Scripting Language is based on the Next Scripting Framework +(NSF) which was developed based on the notion of language oriented +programming. The Next Scripting Frameworks provides C-level support +for defining and hosting multiple object systems in a single Tcl +interpreter. The name of the Next Scripting Framework is derived from +the universal method combinator "next", which was introduced in XOTcl. +The combinator "next" serves as a single instrument for method +combination with filters, per-object and transitive per-class mixin +classes, object methods and multiple inheritance.</p></div> +<div class="paragraph"><p>The definition of NX is fully scripted (e.g. defined in +<code>nx.tcl</code>). The Next Scripting Framework is shipped with three language +definitions, containing NX and XOTcl 2. Most of the existing XOTcl 1 +programs can be used without modification in the Next Scripting +Framework by using XOTcl 2. The Next Scripting Framework requires Tcl +8.5 or newer.</p></div> +</div> +</div> +<div class="sect1"> +<h2 id="_nx_and_its_roots">1. NX and its Roots</h2> +<div class="sectionbody"> +<div class="paragraph"><p>Object oriented extensions of Tcl have quite a +long history. Two of the most prominent early Tcl based OO languages +were <em>incr Tcl</em> (abbreviated as itcl) and Object Tcl (<em>OTcl</em> +<a href="#Wetherall and Lindblad 1995">[Wetherall and Lindblad 1995]</a>). While itcl provides a traditional +C++/Java-like object system, OTcl was following the CLOS approach and +supports a dynamic object system, allowing incremental class and +object extensions and re-classing of objects.</p></div> +<div class="paragraph"><p>Extended Object Tcl (abbreviated as XOTcl <a href="#Neumann and Zdun 2000a">[Neumann and Zdun 2000a]</a>) +is a successor of OTcl and was the first language providing language +support for design patterns. XOTcl extends OTcl by providing namespace +support, adding assertions, dynamic object aggregations, slots and by +introducing per-object and per-class filters and per-object and +per-class mixins.</p></div> +<div class="paragraph"><p>XOTcl was so far released in more than 30 versions. It is described in +its detail in more than 20 papers and serves as a basis for other +object systems like TclOO [Donal ???]. The scripting language <em>NX</em> and +the <em>Next Scripting Framework</em> <a href="#Neumann and Sobernig 2009">[Neumann and Sobernig 2009]</a> extend +the basic ideas of XOTcl by providing support for <em>language-oriented +programming</em>. The the Next Scripting Framework supports multiple +object systems concurrently. Effectively, every object system has +different base classes for creating objects and classes. Therefore, +these object systems can have different interfaces and can +follow different naming conventions for built-in methods. Currently, +the Next Scripting Framework is packaged with three object systems: +NX, XOTcl 2.0, and TclCool (the language introduced by TIP#279).</p></div> +<div class="imageblock" style="text-align:center;"> +<div class="content"> +<img src="languages.png" alt="Languages" width="500" /> +</div> +<div class="title">Figure 1. Language History of the Next Scripting Language</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p>The primary purpose of this document is to introduce NX to beginners. +We expect some prior knowledge of programming languages, and some +knowledge about Tcl. In the following sections we introduce NX by +examples. In later sections we introduce the more advanced concepts of +the language. Conceptually, most of the addressed concepts are very +similar to XOTcl. Concerning the differences between NX and XOTcl, +please refer to the <em>Migration Guide for the Next Scripting Language</em>.</p></div> +</div> +</div> +<div class="sect1"> +<h2 id="_introductory_overview_example_stack">2. Introductory Overview Example: Stack</h2> +<div class="sectionbody"> +<div class="paragraph"><p>A classical programming example is the implementation of a stack, which +is most likely familiar to many readers from many introductory +programming courses. A stack is a last-in first-out data structure +which is manipulated via operations like <code>push</code> (add something to the +stack) and <code>pop</code> remove an entry from the stack. These operations are +called <em>methods</em> in the context of object oriented programming +systems. Primary goals of object orientation are encapsulation and +abstraction. Therefore, we define a common unit (a class) that defines +and encapsulates the behavior of a stack and provides methods to a user +of the data structure that abstract from the actual implementation.</p></div> +<div class="sect2"> +<h3 id="_define_a_class_stack">2.1. Define a Class "Stack"</h3> +<div class="paragraph"><p>In our first example, we define a class named <code>Stack</code> with the methods +<code>push</code> and <code>pop</code>. When an instance of the stack is created (e.g. a +concrete stack <code>s1</code>) the stack will contain an instance variable named +<code>things</code>, initialized with the an empty list.</p></div> +<div class="paragraph" id="xmp-class-stack"><div class="title">Listing 2: Class Stack</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Stack { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Stack of Things +</span> <span class='nx-comment'># +</span> + <span class='nx-keyword'>:variable</span> things {} + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing} { + <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0 <span class='nx-variable'>$thing</span>] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> + } + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> pop {} { + <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0] + <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 1 end] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$top</span> + } +}</pre></div></div> +<div class="paragraph"><p>Typically, classes are defined in NX via <code>nx::Class create</code>, followed +by the name of the new class (here: <code>Stack</code>). The definition of the +stack placed between curly braces and contains here just the method +definitions. Methods of the class are defined via <code>:method</code> followed +by the name of the method, an argument list and the body of the +method, consisting of Tcl and NX statements.</p></div> +<div class="paragraph"><p>When an instance of <code>Stack</code> is created, it will contain an instance +variable named <code>things</code>. If several <code>Stack</code> instances are created, +each of the instances will have their own (same-named but different) +instance variable. The instance variable <code>things</code> is used in our +example as a list for the internal representation of the stack. We +define in a next step the methods to access and modify this list +structure. A user of the stack using the provided methods does not +have to have any knowledge about the name or the structure of the +internal representation (the instance variable <code>things</code>).</p></div> +<div class="paragraph"><p>The method <code>push</code> receives an argument <code>thing</code> which should be placed +on the stack. Note that we do not have to specify the type of the +element on the stack, so we can push strings as well as numbers or +other kind of things. When an element is pushed, we add this element +as the first element to the list <code>things</code>. We insert the element using +the Tcl command <code>linsert</code> which receives the list as first element, +the position where the element should be added as second and the new +element as third argument. To access the value of the instance +variable we use Tcl’s dollar operator followed by the name. The +names of instance variables are preceded with a colon <code>:</code>. Since the +name contains a non-plain character, Tcl requires us to put braces +around the name. The command <code>linsert</code> and its arguments are placed +between square brackets. This means that the function <code>linsert</code> is called and +a new list is returned, where the new element is inserted at the first +position (index 0) in the list <code>things</code>. The result of the <code>linsert</code> +function is assigned again to the instance variable <code>things</code>, which is +updated this way. Finally the method <code>push</code> returns the pushed thing +using the <code>return</code> statement.</p></div> +<div class="paragraph"><p>The method <code>pop</code> returns the most recently stacked element and removes +it from the stack. Therefore, it takes the first element from the list +(using the Tcl command <code>lindex</code>), assigns it to the method-scoped +variable <code>top</code>, removes the element from the instance variable +<code>things</code> (by using the Tcl command <code>lrange</code>) and returns the value +popped element <code>top</code>.</p></div> +<div class="paragraph"><p>This finishes our first implementation of the stack, more enhanced +versions will follow. Note that the methods <code>push</code> and <code>pop</code> are +defined as <code>public</code>; this means that these methods can be +used from all other objects in the system. Therefore, these methods +provide an interface to the stack implementation.</p></div> +<div class="paragraph" id="xmp-using-stack"><div class="title">Listing 3: Using the Stack</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'>#!/usr/bin/env tclsh +</span><span class='nx-keyword'>package</span> <span class='nx-keyword'>require</span> nx + +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Stack { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Stack of Things +</span> <span class='nx-comment'># +</span> .... +} + +Stack <span class='nx-keyword'>create</span> s1 +s1 push a +s1 push b +s1 push c +<span class='nx-keyword'>puts</span> [s1 pop] +<span class='nx-keyword'>puts</span> [s1 pop] +s1 <span class='nx-keyword'>destroy</span></pre></div></div> +<div class="paragraph"><p>Now we want to use the stack. The code snippet in <a href="#xmp-using-stack">Listing 3</a> shows how to use the class Stack in a script. +Since NX is based on Tcl, the script will be called with the Tcl shell +<code>tclsh</code>. In the Tcl shell we have to <code>require package nx</code> to use the +Next Scripting Framework and NX. The next lines contain the definition +of the stack as presented before. Of course, it is as well possible to +make the definition of the stack an own package, such we could simple +say <code>package require stack</code>, or to save the definition of a stack +simply in a file and load it via <code>source</code>.</p></div> +<div class="paragraph"><p>In line 12 we create an instance of the stack, namely the stack object +<code>s1</code>. The object <code>s1</code> is an instance of <code>Stack</code> and has therefore +access to its methods. The methods like <code>push</code> or <code>pop</code> can be invoked +via a command starting with the object name followed by the +method name. In lines 13-15 we push on the stack the values <code>a</code>, then +<code>b</code>, and <code>c</code>. In line 16 we output the result of the <code>pop</code> method +using the Tcl command <code>puts</code>. We will see on standard output the +value+c+ (the last stacked item). The output of the line 17 is the +value <code>b</code> (the previously stacked item). Finally, in line 18 we +destroy the object. This is not necessary here, but shows the life +cycle of an object. In some respects, <code>destroy</code> is the counterpart of +<code>create</code> from line 12.</p></div> +<div class="imageblock" id="fig-class-object" style="text-align:center;"> +<div class="content"> +<img src="object-class-appclass.png" alt="object-class-appclass.png" /> +</div> +<div class="title">Figure 4. Class and Object Diagram</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p><a href="#fig-class-object">Figure 4</a> shows the actual class and +object structure of the first <code>Stack</code> example. Note that the common +root class is <code>nx::Object</code> that contains methods for all objects. +Since classes are as well objects in NX, <code>nx::Class</code> is a +specialization of <code>nx::Object</code>. <code>nx::Class</code> provides methods for +creating objects, such as the method <code>create</code> which is used to create +objects (and classes as well).</p></div> +</div> +<div class="sect2"> +<h3 id="_define_an_object_named_stack">2.2. Define an Object Named "stack"</h3> +<div class="paragraph"><p>The definition of the stack in <a href="#xmp-class-stack">Listing 2</a> +follows the traditional object oriented approach, found in +practically every object oriented programming language: Define a class +with some methods, create instances from this class, and use the +methods defined in the class in the instances of the class.</p></div> +<div class="paragraph"><p>In our next example, we introduce <em>generic objects</em> and <em>object +specific methods</em>. With NX, we can define generic objects, which are +instances of the most generic class <code>nx::Object</code> (sometimes called +<em>common root class</em>). <code>nx::Object</code> is predefined and contains a +minimal set of methods applicable to all NX objects. In this example, +we define a generic object named <code>stack</code> and provide methods for this +object. The methods defined above were methods provided by a class for +objects. Now we define object specific methods, which are methods +applicable only to the object for which they are defined.</p></div> +<div class="paragraph" id="xmp-object-stack"><div class="title">Listing 5: Object stack</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> stack { + + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>variable</span> things {} + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> push {thing} { + <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0 <span class='nx-variable'>$thing</span>] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> + } + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> pop {} { + <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0] + <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 1 end] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$top</span> + } +}</pre></div></div> +<div class="paragraph"><p>The example in <a href="#xmp-object-stack">Listing 5</a> defines the +object <code>stack</code> in a very similar way as the class <code>Stack</code>. But the +following points are different.</p></div> +<div class="ulist"><ul> +<li> +<p> +First, we use <code>nx::Object</code> instead of <code>nx::Class</code> to denote + that we want to create a generic object, not a class. +</p> +</li> +<li> +<p> +We use <code>:object variable</code> to define the variable <code>things</code> just for + this single instance (the object <code>stack</code>). +</p> +</li> +<li> +<p> +The definition for the methods <code>push</code> and <code>pop</code> are the same as + before, but here we defined these with <code>object method</code>. Therefore, + these two methods <code>push</code> and <code>pop</code> are object-specific. +</p> +</li> +</ul></div> +<div class="paragraph"><p>In order to use +the stack, we can use directly the object <code>stack</code> in the same way as +we have used the object <code>s1</code> in <a href="#xmp-using-stack">Listing 3</a> +the class diagram for this the object <code>stack</code>.</p></div> +<div class="imageblock" id="img-object-stack" style="text-align:center;"> +<div class="content"> +<img src="object-stack.png" alt="object-stack.png" /> +</div> +<div class="title">Figure 6. Object stack</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p>A reader might wonder when to use a class <code>Stack</code> or rather an object +<code>stack</code>. A big difference is certainly that one can define easily +multiple instances of a class, while the object is actually a +single, tailored entity. The concept of the object <code>stack</code> is similar to a module, +providing a certain functionality via a common interface, without +providing the functionality to create multiple instances. The reuse of +methods provided by the class to objects is as well a difference. If +the methods of the class are updated, all instances of the class will +immediately get the modified behavior. However, this does not mean that +the reuse for the methods of <code>stack</code> is not possible. NX allows for +example to copy objects (similar to prototype based languages) or to +reuse methods via e.g. aliases (more about this later).</p></div> +<div class="paragraph"><p>Note that we use capitalized names for classes and lowercase names for +instances. This is not required and a pure convention making it easier +to understand scripts without much analysis.</p></div> +</div> +<div class="sect2"> +<h3 id="_implementing_features_using_mixin_classes">2.3. Implementing Features using Mixin Classes</h3> +<div class="paragraph"><p>So far, the definition of the stack methods was pretty minimal. +Suppose, we want to define "safe stacks" that protect e.g. against +stack under-runs (a stack under-run happens, when more <code>pop</code> than +<code>push</code> operations are issued on a stack). Safety checking can be +implemented mostly independent from the implementation details of the +stack (usage of internal data structures). There are as well different +ways of checking the safety. Therefore we say that safety checking is +orthogonal to the stack core implementation.</p></div> +<div class="paragraph"><p>With NX we can define stack-safety as a separate class using methods +with the same names as the implementations before, and "mix" this +behavior into classes or objects. The implementation of <code>Safety</code> in +stack under-runs and to issue error messages, when this happens.</p></div> +<div class="paragraph" id="xmp-class-safety"><div class="title">Listing 7: Class Safety</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Safety { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Implement stack safety by defining an additional +</span> <span class='nx-comment'># instance variable named "count" that keeps track of +</span> <span class='nx-comment'># the number of stacked elements. The methods of +</span> <span class='nx-comment'># this class have the same names and argument lists +</span> <span class='nx-comment'># as the methods of Stack; these methods "shadow" +</span> <span class='nx-comment'># the methods of class Stack. +</span> <span class='nx-comment'># +</span> + <span class='nx-keyword'>:variable</span> count 0 + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing} { + <span class='nx-keyword'>incr</span> :count + <span class='nx-keyword'>next</span> + } + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> pop {} { + <span class='nx-keyword'>if</span> {<span class='nx-variable'>${</span><span class='nx-variable'>:count}</span> == 0} { <span class='nx-keyword'>error</span> <span class='nx-string'>"Stack empty!"</span> } + <span class='nx-keyword'>incr</span> :count -1 + <span class='nx-keyword'>next</span> + } +}</pre></div></div> +<div class="paragraph"><p>Note that all the methods of the class <code>Safety</code> end with <code>next</code>. +This command is a primitive command of NX, which calls the +same-named method with the same argument list as the current +invocation.</p></div> +<div class="paragraph"><p>Assume we save the definition of the class <code>Stack</code> in a file named +<code>Stack.tcl</code> and the definition of the class <code>Safety</code> in a file named +<code>Safety.tcl</code> in the current directory. When we load the classes +<code>Stack</code> and <code>Safety</code> into the same script (see the terminal dialog in +e.g. a certain stack <code>s2</code> as a safe stack, while all other stacks +(such as <code>s1</code>) might be still "unsafe". This can be achieved via the +option <code>-mixin</code> at the object creation time (see line 9 in +option <code>-mixin</code> mixes the class <code>Safety</code> into the new instance <code>s2</code>.</p></div> +<div class="paragraph" id="xmp-using-class-safety"><div class="title">Listing 8: Using the Class Safety</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>% <span class='nx-keyword'>package</span> <span class='nx-keyword'>require</span> nx +2.0 +% <span class='nx-keyword'>source</span> Stack.tcl +::Stack +% <span class='nx-keyword'>source</span> Safety.tcl +::Safety +% Stack <span class='nx-keyword'>create</span> s1 +::s1 +% Stack <span class='nx-keyword'>create</span> s2 -object-mixin Safety +::s2 +% s2 push a +% s2 pop +a +% s2 pop +Stack empty! + +% s1 <span class='nx-keyword'>info</span> precedence +::Stack ::nx::Object + +% s2 <span class='nx-keyword'>info</span> precedence +::Safety ::Stack ::nx::Object</pre></div></div> +<div class="paragraph"><p>When the method <code>push</code> of <code>s2</code> is called, first the method of the +mixin class <code>Safety</code> will be invoked that increments the counter and +continues with <code>next</code> to call the shadowed method, here the method +<code>push</code> of the <code>Stack</code> implementation that actually pushes the item. +The same happens, when <code>s2 pop</code> is invoked, first the method of +<code>Safety</code> is called, then the method of the <code>Stack</code>. When the stack is +empty (the value of <code>count</code> reaches 0), and <code>pop</code> is invoked, the +mixin class <code>Safety</code> generates an error message (raises an exception), +and does not invoke the method of the <code>Stack</code>.</p></div> +<div class="paragraph"><p>The last two commands in +<a href="#xmp-using-class-safety">Listing 8</a> +use introspection to query for the objects +<code>s1</code> and <code>s2</code> in which order the involved classes are processed. This +order is called the <code>precedence order</code> and is obtained via <code>info +precedence</code>. We see that the mixin class <code>Safety</code> is only in use for +<code>s2</code>, and takes there precedence over <code>Stack</code>. The common root class +<code>nx::Object</code> is for both <code>s1</code> and <code>s2</code> the base class.</p></div> +<div class="imageblock" id="img-per-object-mixin" style="text-align:center;"> +<div class="content"> +<img src="per-object-mixin.png" alt="per-object-mixin.png" /> +</div> +<div class="title">Figure 9. Per-object Mixin</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p>Note that in <a href="#xmp-using-class-safety">Listing 8</a>, +the class <code>Safety</code> is only mixed into a single object (here +<code>s2</code>), therefore we refer to this case as a <em>per-object mixin</em>. +<a href="#img-per-object-mixin">Figure 9</a> shows the class +diagram, where the class <code>Safety</code> is used as a per-object mixin for +<code>s2</code>.</p></div> +<div class="paragraph"><p>The mixin class <code>Safety</code> can be used as well in other ways, such as e.g. for +defining classes of safe stacks:</p></div> +<div class="paragraph" id="xmp-class-safestack"><div class="title">Listing 10: Class SafeStack</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># Create a safe stack class by using Stack and mixin +</span><span class='nx-comment'># Safety +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> SafeStack -superclasses Stack -mixins Safety + +SafeStack <span class='nx-keyword'>create</span> s3</pre></div></div> +<div class="paragraph"><p>The difference of a per-class mixin and a per-object mixin is that +the per-class mixin is applicable to all instances of the +class. Therefore, we call these mixins also sometimes instance mixins. +In our example in <a href="#xmp-class-safestack">Listing 10</a>, +<code>Safety</code> is mixed into the definition of +<code>SafeStack</code>. Therefore, all instances of the class <code>SafeStack</code> (here +the instance <code>s3</code>) will be using the safety definitions.</p></div> +<div class="imageblock" id="img-per-class-mixin" style="text-align:center;"> +<div class="content"> +<img src="per-class-mixin.png" alt="per-class-mixin.png" /> +</div> +<div class="title">Figure 11. Per-class Mixin</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p><a href="#img-per-class-mixin">Figure 11</a> shows the class diagram +for this definition. +Note that we could use <code>Safety</code> as well as a per-class mixin on +<code>Stack</code>. In this case, all stacks would be safe stacks and we could +not provide a selective feature selection (which might be perfectly +fine).</p></div> +</div> +<div class="sect2"> +<h3 id="_define_different_kinds_of_stacks">2.4. Define Different Kinds of Stacks</h3> +<div class="paragraph"><p>The definition of <code>Stack</code> is generic and allows all kind of elements +to be stacked. Suppose, we want to use the generic stack definition, +but a certain stack (say, stack <code>s4</code>) should be a stack for integers +only. This behavior can be achieved by the same means as introduced +already in <a href="#xmp-object-stack">Listing 5</a>, namely +object-specific methods.</p></div> +<div class="paragraph" id="xmp-object-integer-stack"><div class="title">Listing 12: Object Integer Stack</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>Stack <span class='nx-keyword'>create</span> s4 { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Create a stack with a object-specific method +</span> <span class='nx-comment'># to check the type of entries +</span> <span class='nx-comment'># +</span> + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> push {thing:integer} { + <span class='nx-keyword'>next</span> + } +}</pre></div></div> +<div class="paragraph"><p>The program snippet in <a href="#xmp-object-integer-stack">Listing 12</a> defines an instance <code>s4</code> of the class +<code>Stack</code> and provides an object specific method for <code>push</code> to implement +an integer stack. The method <code>pull</code> is the same for the integer stack +as for all other stacks, so it will be reused as usual from the class +<code>Stack</code>. The object-specific method <code>push</code> of <code>s4</code> has a value +constraint in its argument list (<code>thing:integer</code>) that makes sure +that only integers can be stacked. In case the argument is not an +integer, an exception will be raised. Of course, one could perform the +value constraint checking as well in the body of the method <code>proc</code> by +accepting an generic argument and by performing the test for the value +in the body of the method. In the case, the passed value is an +integer, the <code>push</code> method of <a href="#xmp-object-integer-stack">Listing 12</a> calls <code>next</code>, and therefore calls the +shadowed generic definition of <code>push</code> as provided by <code>Stack</code>.</p></div> +<div class="paragraph" id="xmp-class-integer-stack"><div class="title">Listing 13: Class IntegerStack</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> IntegerStack -superclass Stack { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Create a Stack accepting only integers +</span> <span class='nx-comment'># +</span> + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing:integer} { + <span class='nx-keyword'>next</span> + } +}</pre></div></div> +<div class="paragraph"><p>An alternative approach is shown in +<a href="#xmp-class-integer-stack">Listing 13</a>, where the class +<code>IntegerStack</code> is defined, using the same method definition +as <code>s4</code>, this time on the class level.</p></div> +</div> +<div class="sect2"> +<h3 id="_define_object_specific_methods_on_classes">2.5. Define Object Specific Methods on Classes</h3> +<div class="paragraph"><p>In our previous examples we defined methods provided by classes +(applicable for their instances) and object-specific methods (methods +defined on objects, which are only applicable for these objects). In +this section, we introduce methods that are defined on the class +objects. Such methods are sometimes called <em>class methods</em> or +<em>static methods</em>.</p></div> +<div class="paragraph"><p>In NX classes are objects, they are specialized objects with +additional methods. Methods for classes are often used for managing +the life-cycles of the instances of the classes (we will come to this +point in later sections in more detail). Since classes are objects, we +can use exactly the same notation as above to define class methods by +using <code>object method</code>. The methods defined on the class object are +in all respects identical with object specific methods shown in the +examples above.</p></div> +<div class="paragraph" id="xmp-stack2"><div class="title">Listing 14: Class Stack2</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Stack2 { + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> available_stacks {} { + <span class='nx-keyword'>return</span> [<span class='nx-keyword'>llength</span> [<span class='nx-keyword'>:info</span> instances]] + } + + <span class='nx-keyword'>:variable</span> things {} + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> push {thing} { + <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>linsert</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0 <span class='nx-variable'>$thing</span>] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$thing</span> + } + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> pop {} { + <span class='nx-keyword'>set</span> top [<span class='nx-keyword'>lindex</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 0] + <span class='nx-keyword'>set</span> :things [<span class='nx-keyword'>lrange</span> <span class='nx-variable'>${</span><span class='nx-variable'>:things}</span> 1 end] + <span class='nx-keyword'>return</span> <span class='nx-variable'>$top</span> + } +} + +Stack2 <span class='nx-keyword'>create</span> s1 +Stack2 <span class='nx-keyword'>create</span> s2 + +<span class='nx-keyword'>puts</span> [Stack2 available_stacks]</pre></div></div> +<div class="paragraph"><p>The class <code>Stack2</code> in <a href="#xmp-stack2">Listing 14</a> consists of the +earlier definition of the class <code>Stack</code> and is extended by the +class-specific method <code>available_stacks</code>, which returns the +current number of instances of the stack. The final command <code>puts</code> +(line 26) prints 2 to the console.</p></div> +<div class="imageblock" id="img-stack2" style="text-align:center;"> +<div class="content"> +<img src="stack2.png" alt="stack2.png" /> +</div> +<div class="title">Figure 15. Stack2</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p>The class diagram in <a href="#img-stack2">Figure 15</a> shows the +diagrammatic representation of the class object-specific method +<code>available_stacks</code>. Since every class is a specialization of the +common root class <code>nx::Object</code>, the common root class is often omitted +from the class diagrams, so it was omitted here as well in the diagram.</p></div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_basic_language_features_of_nx">3. Basic Language Features of NX</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_variables_and_properties">3.1. Variables and Properties</h3> +<div class="paragraph"><p>In general, NX does not need variable declarations. It allows one to +create or modify variables on the fly by using for example the Tcl +commands <code>set</code> and <code>unset</code>. Depending on the variable name (or more +precisely, depending on the variable name’s prefix consisting of +colons "<code>:</code>") a variable is either local to a method, or it is an +instance variable, or a global variable. The rules are:</p></div> +<div class="ulist"><ul> +<li> +<p> +A variable without any colon prefix refers typically to a method + scoped variable. Such a variable is created during the invocation + of the method, and it is deleted, when the method ends. In the + example below, the variable <code>a</code> is method scoped. +</p> +</li> +<li> +<p> +A variable with a single colon prefix refers to an instance + variable. An instance variable is part of the object; when the + object is destroyed, its instance variables are deleted as well. In the + example below, the variable <code>b</code> is an instance variable. +</p> +</li> +<li> +<p> +A variable with two leading colons refers to a global variable. The + lifespan of a globale variable ends when the variable is explicitly + unset or the script terminates. Variables, which are placed in Tcl + namespaces, are also global variables. In the example below, the + variable <code>c</code> is a global variable. +</p> +</li> +</ul></div> +<div class="paragraph" id="xmp-var-resolver"><div class="title">Listing 16: Scopes of Variables</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Foo { + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo args {...} + <span class='nx-comment'># "a" is a method scoped variable +</span> <span class='nx-keyword'>set</span> a 1 + <span class='nx-comment'># "b" is an Instance variable +</span> <span class='nx-keyword'>set</span> :b 2 + <span class='nx-comment'># "c" is a global variable/namespaced variable +</span> <span class='nx-keyword'>set</span> ::c 3 + } +}</pre></div></div> +<div class="paragraph"><p><a href="#xmp-var-resolver">Listing 16</a> shows a method <code>foo</code> +of some class <code>Foo</code> referring to differently scoped variables.</p></div> +<div class="sect3"> +<h4 id="_properties_configurable_instance_variables">3.1.1. Properties: Configurable Instance Variables</h4> +<div class="paragraph"><p>As described above, there is no need to declare instance variables in +NX. In many cases, a developer might want to define some value +constraints for variables, or to provide defaults, or to make +variables configurable upon object creation. Often, variables are +"inherited", meaning that the variables declared in a general class +are also available in a more specialized class. For these purposes NX +provides <em>variable handlers</em> responsible for the management of +instance variables. We distinguish in NX between configurable +variables (called <code>property</code>) and variables that are not configurable +(called <code>variable</code>).</p></div> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>A <strong>property</strong> is a definition of a configurable instance variable.</p></div> +</div></div> +<div class="paragraph"><p>The term configurable means that (a) one can provide at creation time of +an instance a value for this variable, and (b), one can query the +value via the accessor function <code>cget</code> and (c), one can change the +value of the variable via <code>configure</code> at runtime. Since the general +accessor function <code>cget</code> and <code>configure</code> are available, an application +developer does not have to program own accessor methods. When value +checkers are provided, each time, the value of the variable is to be +changed, the constrained are checked as well.</p></div> +<div class="imageblock" id="img-person-student" style="text-align:center;"> +<div class="content"> +<img src="person-student.png" alt="person-student.png" /> +</div> +<div class="title">Figure 17. Classes Person and Student</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p>The class diagram above defines the classes <code>Person</code> and +<code>Student</code>. For both classes, configurable instance variable are +specified by defining these as properties. The listing below shows +an implementation of this conceptual model in NX.</p></div> +<div class="paragraph" id="xmp-properties"><div class="title">Listing 18: Properties</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># Define a class Person with properties "name" +</span><span class='nx-comment'># and "birthday" +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Person { + <span class='nx-keyword'>:property</span> name:required + <span class='nx-keyword'>:property</span> birthday +} + +<span class='nx-comment'># +</span><span class='nx-comment'># Define a class Student as specialization of Person +</span><span class='nx-comment'># with additional properties +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Student -superclass Person { + <span class='nx-keyword'>:property</span> matnr:required + <span class='nx-keyword'>:property</span> {oncampus:boolean true} +} + +<span class='nx-comment'># +</span><span class='nx-comment'># Create instances using configure parameters +</span><span class='nx-comment'># for the initialization +</span><span class='nx-comment'># +</span>Person <span class='nx-keyword'>create</span> p1 -name Bob +Student <span class='nx-keyword'>create</span> s1 -name Susan -matnr 4711 + +<span class='nx-comment'># Access property value via accessor method +</span><span class='nx-keyword'>puts</span> <span class='nx-string'>"The name of s1 is [s1 cget -name]"</span></pre></div></div> +<div class="paragraph"><p>By defining <code>name</code> and <code>birthday</code> as properties of <code>Person</code>, NX makes +these configurable. When we create an instance of <code>Person</code> named +<code>p1</code>, we can provide a value for e.g. the name by specifying <code>-name</code> +during creation. The properties result in non-positional configure parameters +which can be provided in any order. In our listing, we create an instance of +<code>Person</code> using the configure parameter <code>name</code> and provide the value of +<code>Bob</code> to the instance variable <code>name</code>.</p></div> +<div class="paragraph"><p>The class <code>Student</code> is defined as a specialization of <code>Person</code> with +two additional properties: <code>matnr</code> and <code>oncampus</code>. The property +<code>matnr</code> is required (it has to be provided, when an instance of this +class is created), and the property <code>oncampus</code> is boolean, and is per +default set to <code>true</code>. Note that the class <code>Student</code> inherits the +properties of <code>Person</code>. So, <code>Student</code> has four properties in total.</p></div> +<div class="paragraph"><p>The property definitions provide the <code>configure parameters</code> for +instance creation. Many other languages require such parameters to be +passed via arguments of a constructor, which is often error prone, +when values are to be passed to superclasses. Also in dynamic +languages, the relationships between classes can be easily changed, +and different superclasses might have different requirements in their +constructors. The declarative approach in NX reduces the need for +tailored constructor methods significantly.</p></div> +<div class="paragraph"><p>Note that the property <code>matnr</code> of class <code>Student</code> is required. This +means, that if we try to create an instance of <code>Student</code>, a runtime +exception will be triggered. The property <code>oncamups</code> is boolean and +contains a default value. Providing a default value means that +whenever we create an instance of this class the object will contain +such an instance variable, even when we provide no value via the +configure parameters.</p></div> +<div class="paragraph"><p>In our listing, we create an instance of <code>Student</code> using the two +configure parameters <code>name</code> and <code>matnr</code>. Finally, we use method <code>cget</code> +to obtain the value of the instance variable <code>name</code> of object <code>s1</code>.</p></div> +</div> +<div class="sect3"> +<h4 id="_non_configurable_instance_variables">3.1.2. Non-configurable Instance Variables</h4> +<div class="paragraph"><p>In practice, not all instance variables should be configurable. But +still, we want to be able to provide defaults similar to +properties. To define non-configurable instance variables the +predefined method <code>variable</code> can be used. Such instance variables are +often used for e.g. keeping the internal state of an object. The +usage of <code>variable</code> is in many respects similar to <code>property</code>. One +difference is, that <code>property</code> uses the same syntax as for method +parameters, whereas <code>variable</code> receives the default value as a +separate argument (similar to the <code>variable</code> command in plain +Tcl). The introductory Stack example in <a href="#xmp-class-stack">Listing 2</a> uses already the method <code>variable</code>.</p></div> +<div class="paragraph" id="xmp-variable"><div class="title">Listing 19: Declaring Variables</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Base { + <span class='nx-keyword'>:variable</span> x 1 + <span class='nx-comment'># ... +</span>} + +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Derived -superclass Base { + <span class='nx-keyword'>:variable</span> y 2 + <span class='nx-comment'># ... +</span>} + +<span class='nx-comment'># Create instance of the class Derived +</span>Derived <span class='nx-keyword'>create</span> d1 + +<span class='nx-comment'># Object d1 has instance variables +</span><span class='nx-comment'># x == 1 and y == 2</span></pre></div></div> +<div class="paragraph"><p>Note that the variable definitions are inherited in the same way as +properties. The example in <a href="#xmp-variable">Listing 19</a> shows a +class <code>Derived</code> that inherits from <code>Base</code>. When an instance <code>d1</code> is +created, it will contain the two instance variables <code>x</code> and <code>y</code>. +Note that the variable declarations from <code>property</code> and <code>variable</code> are +used to initialize (and to configure) the instances variables of an object.</p></div> +<div class="paragraph" id="xmp-constructor"><div class="title">Listing 20: Setting Variables in the Constructor</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Base2 { + <span class='nx-comment'># ... +</span> <span class='nx-keyword'>:method</span> <span class='nx-keyword'>init</span> {} { + <span class='nx-keyword'>set</span> :x 1 + <span class='nx-comment'># .... +</span> } +} + +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Derived2 -superclass Base2 { + <span class='nx-comment'># ... +</span> <span class='nx-keyword'>:method</span> <span class='nx-keyword'>init</span> {} { + <span class='nx-keyword'>set</span> :y 2 + <span class='nx-keyword'>next</span> + <span class='nx-comment'># .... +</span> } +} + +<span class='nx-comment'># Create instance of the class Derived2 +</span>Derived2 <span class='nx-keyword'>create</span> d2</pre></div></div> +<div class="paragraph"><p>In many other object oriented languages, the instance variables are +initialized solely by the constructor (similar to class <code>Derived2</code> in +<a href="#xmp-constructor">Listing 20</a>). This approach is certainly +also possible in NX. Note that the approach using constructors +requires an explicit method chaining between the constructors and is +less declarative than the approach in NX using <code>property</code> and <code>variable</code>.</p></div> +<div class="paragraph"><p>Both, <code>property</code> and <code>variable</code> provide much more functionalities. One +can for example declare <code>public</code>, <code>protected</code> or <code>private</code> accessor +methods, or one can define variables to be incremental (for +e.g. adding values to a list of values), or one can define variables +specific behavior.</p></div> +</div> +</div> +<div class="sect2"> +<h3 id="_method_definitions">3.2. Method Definitions</h3> +<div class="paragraph"><p>The basic building blocks of an object oriented program are object and +classes, which contain named pieces of code, the methods.</p></div> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p><strong>Methods</strong> are subroutines (pieces of code) associated with objects +and/or classes. A method has a name, receives optionally arguments +during invocation and returns a value.</p></div> +</div></div> +<div class="paragraph"><p>Plain Tcl provides subroutines, which are not associated with objects +or classes. Tcl distinguishes between +proc+s (scripted subroutines) +and commands (system-languages implemented subroutines).</p></div> +<div class="paragraph"><p>Methods might have different scopes, defining, on which kind of +objects these methods are applicable to. These are described in more +detail later on. For the time being, we deal here with methods defined +on classes, which are applicable for the instance of these classes.</p></div> +<div class="sect3"> +<h4 id="_scripted_methods">3.2.1. Scripted Methods</h4> +<div class="paragraph"><p>Since NX is a scripting language, most methods are most likely +scripted methods, in which the method body contains Tcl code.</p></div> +<div class="paragraph" id="xmp-fido1"><div class="title">Listing 21: Scripted method</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Define a class +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Dog { + + <span class='nx-comment'># Define a scripted method for the class +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bark {} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"[self] Bark, bark, bark."</span> + } +} + +<span class='nx-comment'># Create an instance of the class +</span>Dog <span class='nx-keyword'>create</span> fido + +<span class='nx-comment'># The following line prints "::fido Bark, bark, bark." +</span>fido bark</pre></div></div> +<div class="paragraph"><p>In the example above we create a class <code>Dog</code> with a scripted method +named <code>bark</code>. The method body defines the code, which is executed when +the method is invoked. In this example, the method <code>bar</code> prints out a +line on the terminal starting with the object name (this is determined +by the built in command <code>self</code>) followed by "Bark, bark, bark.". This +method is defined on a class and applicable to instances of the class +(here the instance <code>fido</code>).</p></div> +</div> +<div class="sect3"> +<h4 id="_c_implemented_methods">3.2.2. C-implemented Methods</h4> +<div class="paragraph"><p>Not all of the methods usable in NX are scripted methods; many +predefined methods are defined in the underlying system language, +which is typically C. For example, in <a href="#xmp-fido1">Listing 21</a> we +used the method <code>create</code> to create the class <code>Dog</code> and to create the +dog instance <code>fido</code>. These methods are implemented in C in the next +scripting framework.</p></div> +<div class="paragraph"><p>C-implemented methods are not only provided by the underlying +framework but might be as well defined by application developers. This +is an advanced topic, not covered here. However, application developer +might reuse some generic C code to define their own C-implemented +methods. Such methods are for example <em>accessors</em>, <em>forwarders</em> and +<em>aliases</em>.</p></div> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>An <strong>accessor method</strong> is a method that accesses instance +variables of an object. A call to an accessor +without arguments uses the accessor as a getter, obtaining the actual +value of the associated variable. A call to an accessor with an +argument uses it as a setter, setting the value of the associated +variable.</p></div> +</div></div> +<div class="paragraph"><p>NX provides support for C-implemented accessor methods. Accessors have +already been mentioned in the section about properties. When +the option <code>-accessor public|protected|private</code> is provided to a +<code>variable</code> or <code>property</code> definition, NX creates automatically a +same-named accessors method.</p></div> +<div class="paragraph" id="xmp-fido2"><div class="title">Listing 22: Accessor Methods</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Dog { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bark {} { <span class='nx-keyword'>puts</span> <span class='nx-string'>"[self] Bark, bark, bark."</span> } + <span class='nx-keyword'>:method</span> <span class='nx-keyword'>init</span> {} { Tail <span class='nx-keyword'>create</span> [<span class='nx-keyword'>self</span>]::tail} +} + +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Tail { + <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>public</span> {length:double 5} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> wag {} {<span class='nx-keyword'>return</span> Joy} +} + +<span class='nx-comment'># Create an instance of the class +</span>Dog <span class='nx-keyword'>create</span> fido + +<span class='nx-comment'># Use the accessor "length" as a getter, to obtain the value +</span><span class='nx-comment'># of a property. The following call returns the length of the +</span><span class='nx-comment'># tail of fido +</span>fido::tail length get + +<span class='nx-comment'># Use the accessor "length" as a setter, to alter the value +</span><span class='nx-comment'># of a property. The following call changes the length of +</span><span class='nx-comment'># the tail of fido +</span>fido::tail length <span class='nx-keyword'>set</span> 10 + +<span class='nx-comment'># Proving an invalid values will raise an error +</span>fido::tail length <span class='nx-keyword'>set</span> <span class='nx-string'>"Hello"</span></pre></div></div> +<div class="paragraph"><p><a href="#xmp-fido2">Listing 22</a> shows an extended example, where every dog +has a tail. The object <code>tail</code> is created as a subobject of the dog in +the constructor <code>init</code>. The subobject can be accessed by providing the +full name of the subobject <code>fido::tail</code>. The method <code>length</code> is an +C-implemented accessor, that enforces the value constraint (here a +floating point number, since length uses the value constraint +<code>double</code>). Line 25 will therefore raise an exception, since the +provided values cannot be converted to a double number.</p></div> +<div class="paragraph" id="xmp-fido3"><div class="title">Listing 23: Forwarder Methods</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Dog { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bark {} { <span class='nx-keyword'>puts</span> <span class='nx-string'>"[self] Bark, bark, bark."</span> } + <span class='nx-keyword'>:method</span> <span class='nx-keyword'>init</span> {} { + Tail <span class='nx-keyword'>create</span> [<span class='nx-keyword'>self</span>]::tail + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>forward</span> wag [<span class='nx-keyword'>self</span>]::tail wag + } +} + +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Tail { + <span class='nx-keyword'>:property</span> {length 5} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> wag {} {<span class='nx-keyword'>return</span> Joy} +} + +<span class='nx-comment'># Create an instance of the class +</span>Dog <span class='nx-keyword'>create</span> fido + +<span class='nx-comment'># The invocation of "fido wag" is delegated to "fido::tail wag". +</span><span class='nx-comment'># Therefore, the following method returns "Joy". +</span>fido wag</pre></div></div> +<div class="paragraph"><p><a href="#xmp-fido3">Listing 23</a> again extends the example by adding a +forwarder named <code>wag</code> to the object (e.g. <code>fido</code>). The forwarder +redirects all calls of the form <code>fido wag</code> with arbitrary arguments to +the subobject <code>fido::tail</code>.</p></div> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>A <strong>forwarder method</strong> is a +C-implemented method that redirects an invocation for a certain method +to either a method of another object or to some other method of the +same object. Forwarding an invocation of a method to some other +object is a means of delegation.</p></div> +</div></div> +<div class="paragraph"><p>The functionality of the forwarder can just as well be implemented as +a scripted method, but for the most common cases, the forward +implementation is more efficient, and the <code>forward</code> method expresses +the intention of the developer.</p></div> +<div class="paragraph"><p>The method <code>forwarder</code> has several options to change e.g. the order of +the arguments, or to substitute certain patterns in the argument list +etc. This will be described in later sections.</p></div> +</div> +<div class="sect3"> +<h4 id="_method_aliases">3.2.3. Method-Aliases</h4> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>An <strong>alias method</strong> is a means to register either an existing method, +or a Tcl proc, or a Tcl command as a method with the provided +name on a class or object.</p></div> +</div></div> +<div class="paragraph"><p>In some way, the method alias is a restricted form of a forwarder, +though it does not support delegation to different objects or argument +reordering. The advantage of the method alias compared to a forwarder +is that it has close to zero overhead, especially for aliasing +c-implemented methods.</p></div> +<div class="paragraph" id="xmp-fido4"><div class="title">Listing 24: Method-Alias</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Dog { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bark {} { <span class='nx-keyword'>puts</span> <span class='nx-string'>"[self] Bark, bark, bark."</span> } + + <span class='nx-comment'># Define a public alias for the method "bark" +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>alias</span> warn [<span class='nx-keyword'>:info</span> <span class='nx-keyword'>method</span> handle bark] + <span class='nx-comment'># ... +</span>} + +<span class='nx-comment'># Create an instance of the class +</span>Dog <span class='nx-keyword'>create</span> fido + +<span class='nx-comment'># The following line prints "::fido Bark, bark, bark." +</span>fido warn</pre></div></div> +<div class="paragraph"><p><a href="#xmp-fido4">Listing 24</a> extends the last example by defining an +alias for the method <code>bark</code>. The example only shows the bare +mechanism. In general, method aliases are very powerful means for +reusing pre-existing functionality. The full object system of NX and +XOTcl2 is built from aliases, reusing functionality provided by the +next scripting framework under different names. Method aliases +are as well a means for implementing traits in NX.</p></div> +</div> +</div> +<div class="sect2"> +<h3 id="_method_protection">3.3. Method Protection</h3> +<div class="paragraph"><p>All kinds of methods might have different kind of protections in NX. +The call-protection defines from which calling context methods might +be called. The Next Scripting Framework supports as well redefinition +protection for methods.</p></div> +<div class="paragraph"><p>NX distinguishes between <code>public</code>, <code>protected</code> and <code>private</code> methods, +where the default call-protection is <code>protected</code>.</p></div> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>A <strong>public</strong> method can be called from every context. A <strong>protected</strong> +method can only be invoked from the same object. A <strong>private</strong> method +can only be invoked from methods defined on the same entity +(defined on the same class or on the same object) via the invocation +with the local flag (i.e. "<code>: -local foo</code>").</p></div> +</div></div> +<div class="paragraph"><p>All kind of method protections are applicable for all kind of methods, +either scripted or C-implemented.</p></div> +<div class="paragraph"><p>The distinction between public and protected leads to interfaces for +classes and objects. Public methods are intended for consumers of +these entities. Public methods define the intended ways of providing +methods for external usages (usages, from other objects or +classes). Protected methods are intended for the implementor of the +class or subclasses and not for public usage. The distinction between +protected and public reduces the coupling between consumers and the +implementation, and offers more flexibility to the developer.</p></div> +<div class="paragraph" id="xmp-protected-method"><div class="title">Listing 25: Protected Methods</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Foo { + + <span class='nx-comment'># Define a public method +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { + <span class='nx-comment'># .... +</span> <span class='nx-keyword'>return</span> [:helper] + } + + <span class='nx-comment'># Define a protected method +</span> <span class='nx-keyword'>:method</span> helper {} { + <span class='nx-keyword'>return</span> 1 + } +} + +<span class='nx-comment'># Create an instance of the class: +</span>Foo <span class='nx-keyword'>create</span> f1 + +<span class='nx-comment'># The invocation of the public method "foo" returns 1 +</span>f1 foo + +<span class='nx-comment'># The invocation of the protected method "helper" raises an error: +</span>f1 helper</pre></div></div> +<div class="paragraph"><p>The example above uses <code>:protected method helper …</code>. We could have +used here as well <code>:method helper …</code>, since the default method +call-protection is already protected.</p></div> +<div class="paragraph"><p>The method call-protection of <code>private</code> goes one step further and +helps to hide implementation details also for implementors of +subclasses. Private methods are a means for avoiding unanticipated name +clashes. Consider the following example:</p></div> +<div class="paragraph" id="xmp-private-method"><div class="title">Listing 26: Private Methods</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Base { + <span class='nx-keyword'>:private</span> <span class='nx-keyword'>method</span> helper {a b} {<span class='nx-keyword'>expr</span> {<span class='nx-variable'>$a</span> + <span class='nx-variable'>$b</span>}} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {a b} {: -local helper <span class='nx-variable'>$a</span> <span class='nx-variable'>$b</span>} +} + +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Sub -superclass Base { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bar {a b} {: -local helper <span class='nx-variable'>$a</span> <span class='nx-variable'>$b</span>} + <span class='nx-keyword'>:private</span> <span class='nx-keyword'>method</span> helper {a b} {<span class='nx-keyword'>expr</span> {<span class='nx-variable'>$a</span> * <span class='nx-variable'>$b</span>}} + <span class='nx-keyword'>:create</span> s1 +} + +s1 foo 3 4 ;<span class='nx-comment'># returns 7 +</span>s1 bar 3 4 ;<span class='nx-comment'># returns 12 +</span>s1 helper 3 4 ;<span class='nx-comment'># raises error: unable to dispatch method helper</span></pre></div></div> +<div class="paragraph"><p>The base class implements a public method <code>foo</code> using the helper +method named <code>helper</code>. The derived class implements a as well a public +method <code>bar</code>, which is also using a helper method named <code>helper</code>. When +an instance <code>s1</code> is created from the derived class, the method <code>foo</code> +is invoked which uses in turn the private method of the base +class. Therefore, the invocation <code>s1 foo 3 4</code> returns its sum. If +the <code>local</code> flag had not beed used in helper, <code>s1</code> would +have tried to call the helper of <code>Sub</code>, which would be incorrect. For +all other purposes, the private methods are "invisible" in all +situations, e.g., when mixins are used, or within the <code>next</code>-path, etc.</p></div> +<div class="paragraph"><p>By using the <code>-local</code> flag at the call site it is possible to invoke +only the local definition of the method. If we would call the method +without this flag, the resolution order would be the standard +resolution order, starting with filters, mixins, object methods +and the full intrinsic class hierarchy.</p></div> +<div class="paragraph"><p>NX supports the modifier <code>private</code> for methods and properties. In all +cases <code>private</code> is an instrument to avoid unanticipated interactions +and means actually "accessible for methods defined on the same entity +(object or class)". The main usage for <code>private</code> is to improve +locality of the code e.g. for compositional operations.</p></div> +<div class="paragraph"><p>In order to improve locality for properties, a private property +defines therefore internally a variable with a different name to avoid +unintended interactions. The variable should be accessed via the +private accessor, which can be invoked with the <code>-local</code> flag. In the +following example class <code>D</code> introduces a private property with the +same name as a property in the superclass.</p></div> +<div class="paragraph" id="xmp-private-properties"><div class="title">Listing 27: Private Properties</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># Define a class C with a property "x" and a public accessor +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>public</span> {x c} +} + +<span class='nx-comment'># +</span><span class='nx-comment'># Define a subclass D with a private property "x" +</span><span class='nx-comment'># and a method bar, which is capable of accessing +</span><span class='nx-comment'># the private property. +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> D -superclass C { + <span class='nx-keyword'>:property</span> -accessor <span class='nx-keyword'>private</span> {x d} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bar {p} {<span class='nx-keyword'>return</span> [: -local <span class='nx-variable'>$p</span> get]} +} + +<span class='nx-comment'># +</span><span class='nx-comment'># The private and public (or protected) properties +</span><span class='nx-comment'># define internally separate variable that do not +</span><span class='nx-comment'># conflict. +</span><span class='nx-comment'># +</span>D <span class='nx-keyword'>create</span> d1 +<span class='nx-keyword'>puts</span> [d1 x get] ;<span class='nx-comment'># prints "c" +</span><span class='nx-keyword'>puts</span> [d1 bar x] ;<span class='nx-comment'># prints "d"</span></pre></div></div> +<div class="paragraph"><p>Without the <code>private</code> definition of the property, the definition of +property <code>x</code> in class <code>D</code> would shadow the +definition of the property in the superclass <code>C</code> for its instances +(<code>d1 x</code> or <code>set :x</code> would return <code>d</code> instead of <code>c</code>).</p></div> +</div> +<div class="sect2"> +<h3 id="_applicability_of_methods">3.4. Applicability of Methods</h3> +<div class="paragraph"><p>As defined above, a method is a subroutine defined on an object or +class. This object (or class) contains the method. If the object (or +class) is deleted, the contained methods will be deleted as well.</p></div> +<div class="sect3"> +<h4 id="_instance_methods">3.4.1. Instance Methods</h4> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>Typically, methods are defined on a class, and the methods defined on the +class are applicable to the instances (direct or indirect) of this +class. These methods are called <strong>instance methods</strong>.</p></div> +</div></div> +<div class="paragraph"><p>In the following example method, <code>foo</code> is an instance method defined +on class <code>C</code>.</p></div> +<div class="paragraph" id="xmp-instance-applicable"><div class="title">Listing 28: Methods applicable for instances</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>return</span> 1} + <span class='nx-keyword'>:create</span> c1 +} + +<span class='nx-comment'># Method "foo" is defined on class "C" +</span><span class='nx-comment'># and applicable to the instances of "C" +</span>c1 foo</pre></div></div> +<div class="paragraph"><p>There are many programming languages that only allow these types of methods. +However, NX also allows methods to be defined on objects.</p></div> +</div> +<div class="sect3"> +<h4 id="_object_methods">3.4.2. Object Methods</h4> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>Methods defined on objects are <strong>object methods</strong>. Object +methods are only applicable on the object, on which they are defined. +Object methods cannot be inherited from other objects.</p></div> +</div></div> +<div class="paragraph"><p>The following example defines an object method <code>bar</code> on the +instance <code>c1</code> of class <code>C</code>, and as well as the object specific method +<code>baz</code> defined on the object <code>o1</code>. An object method is defined +via <code>object method</code>.</p></div> +<div class="paragraph"><p>Note that we can define a object method that shadows (redefines) +for this object methods provided from classes.</p></div> +<div class="paragraph" id="xmp-object-applicable1"><div class="title">Listing 29: Object Method</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>return</span> 1} + <span class='nx-keyword'>:create</span> c1 { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>return</span> 2} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {} {<span class='nx-keyword'>return</span> 3} + } +} + +<span class='nx-comment'># Method "bar" is an object specific method of "c1" +</span>c1 bar + +<span class='nx-comment'># object-specific method "foo" returns 2 +</span>c1 foo + +<span class='nx-comment'># Method "baz" is an object specific method of "o1" +</span><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o1 { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> baz {} {<span class='nx-keyword'>return</span> 4} +} +o1 baz</pre></div></div> +</div> +<div class="sect3"> +<h4 id="_class_methods">3.4.3. Class Methods</h4> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>A <strong>class method</strong> is a method defined on a class, which is only +applicable to the class object itself. The class method is actually +an object method of the class object.</p></div> +</div></div> +<div class="paragraph"><p>In NX, all classes are objects. Classes are in NX special kind of +objects that have e.g. the ability to create instances and to provide +methods for the instances. Classes manage their instances. The general +method set for classes is defined on the meta-classes (more about +this later).</p></div> +<div class="paragraph"><p>The following example defines a public class method <code>bar</code> on class +<code>C</code>. The class method is specified by using the modifier <code>object</code> in +front of <code>method</code> in the method definition command.</p></div> +<div class="paragraph" id="xmp-object-applicable2"><div class="title">Listing 30: Class Methods</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-comment'># +</span> <span class='nx-comment'># Define a class method "bar" and an instance +</span> <span class='nx-comment'># method "foo" +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {} {<span class='nx-keyword'>return</span> 2} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} {<span class='nx-keyword'>return</span> 1} + + <span class='nx-comment'># +</span> <span class='nx-comment'># Create an instance of the current class +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:create</span> c1 +} + +<span class='nx-comment'># Method "bar" is a class method of class "C" +</span><span class='nx-comment'># therefore applicable on the class object "C" +</span>C bar + +<span class='nx-comment'># Method "foo" is an instance method of "C" +</span><span class='nx-comment'># therefore applicable on instance "c1" +</span>c1 foo + +<span class='nx-comment'># When trying to invoke the class method on the +</span><span class='nx-comment'># instance, an error will be raised. +</span>c1 bar</pre></div></div> +<div class="paragraph"><p>In some other object-oriented programming languages, class methods +are called "static methods".</p></div> +</div> +</div> +<div class="sect2"> +<h3 id="_ensemble_methods">3.5. Ensemble Methods</h3> +<div class="paragraph"><p>NX provides <em>ensemble methods</em> as a means to structure the method name +space and to group related methods. Ensemble methods are similar in +concept to Tcl’s ensemble commands.</p></div> +<div class="exampleblock"> +<div class="content"> +<div class="paragraph"><p>An <strong>ensemble method</strong> is a form of a hierarchical method consisting of +a container method and sub-methods. The first argument of the +container method is interpreted as a selector (the sub-method). Every +sub-method can be an container method as well.</p></div> +</div></div> +<div class="paragraph"><p>Ensemble methods provide a means to group related commands together, +and they are extensible in various ways. It is possible to add +sub-methods at any time to existing ensembles. Furthermore, it is +possible to extend ensemble methods via mixin classes.</p></div> +<div class="paragraph"><p>The following example defines an ensemble method for <code>string</code>. An +ensemble method is defined when the provide method name contains a +space.</p></div> +<div class="paragraph" id="xmp-ensemble-methods"><div class="title">Listing 31: Ensemble Method</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { + + <span class='nx-comment'># Define an ensemble method "string" with sub-methods +</span> <span class='nx-comment'># "length", "tolower" and "info" +</span> + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> <span class='nx-string'>"string length"</span> {x} {....} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> <span class='nx-string'>"string tolower"</span> {x} {...} + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> <span class='nx-string'>"string info"</span> {x} {...} + <span class='nx-comment'>#... +</span> <span class='nx-keyword'>:create</span> c1 +} + +<span class='nx-comment'># Invoke the ensemble method +</span>c1 <span class='nx-keyword'>string</span> length <span class='nx-string'>"hello world"</span></pre></div></div> +</div> +<div class="sect2"> +<h3 id="_method_resolution">3.6. Method Resolution</h3> +<div class="paragraph"><p>When a method is invoked, the applicable method is searched in the +following order:</p></div> +Per-object Mixins -> Per-class Mixins -> Object -> Intrinsic Class Hierarchy +<div class="paragraph"><p>In the case, no mixins are involved, first the object is searched for +an object method with the given name, and then the class hierarchy +of the object. The method can be defined multiple times on the search +path, so some of these method definitions might be <em>shadowed</em> by the +more specific definitions.</p></div> +<div class="paragraph" id="xmp-method-resolution"><div class="title">Listing 32: Method Resolution with Intrinsic Classes</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> C { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { + <span class='nx-keyword'>return</span> <span class='nx-string'>"C foo: [next]"</span> + } +} + +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> D -superclass C { + + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { + <span class='nx-keyword'>return</span> <span class='nx-string'>"D foo: [next]"</span> + } + + <span class='nx-keyword'>:create</span> d1 { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {} { + <span class='nx-keyword'>return</span> <span class='nx-string'>"d1 foo: [next]"</span> + } + } +} + +<span class='nx-comment'># Invoke the method foo +</span>d1 foo +<span class='nx-comment'># result: "d1 foo: D foo: C foo: " +</span> +<span class='nx-comment'># Query the precedence order from NX via introspection +</span>d1 <span class='nx-keyword'>info</span> precedence +<span class='nx-comment'># result: "::D ::C ::nx::Object"</span></pre></div></div> +<div class="paragraph"><p>Consider the example in +<a href="#xmp-method-resolution">Listing 32</a>. When the method +<code>foo</code> is invoked on object <code>d1</code>, the object method has the highest +precedence and is therefore invoked. The object methods shadows +the same-named methods in the class hierarchy, namely the method <code>foo</code> +of class <code>D</code> and the method <code>foo</code> of class <code>C</code>. The shadowed methods +can be still invoked, either via the primitive <code>next</code> or via method +handles (we used already method handles in the section about method +aliases). In the example above, <code>next</code> calls the shadowed method and +add their results to the results of every method. So, the final result +contains parts from <code>d1</code>, <code>D</code> and <code>C</code>. Note that the topmost <code>next</code> +in method <code>foo</code> of class <code>C</code> shadows no method <code>foo</code> and simply +returns empty (and not an error message).</p></div> +<div class="paragraph"><p>The introspection method <code>info precedence</code> provides information about +the order, in which classes processed during method resolution.</p></div> +<div class="paragraph" id="xmp-method-resolution2"><div class="title">Listing 33: Method Resolution with Mixin Classes</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> M1 { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { <span class='nx-keyword'>return</span> <span class='nx-string'>"M1 foo: [next]"</span>} +} +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> M2 { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {} { <span class='nx-keyword'>return</span> <span class='nx-string'>"M2 foo: [next]"</span>} +} + +<span class='nx-comment'># +</span><span class='nx-comment'># "d1" is created based on the definitions of the last example +</span><span class='nx-comment'># +</span><span class='nx-comment'># Add the methods from "M1" as per-object mixin to "d1" +</span>d1 <span class='nx-keyword'>object</span> mixins add M1 + +<span class='nx-comment'># +</span><span class='nx-comment'># Add the methods from "M2" as per-class mixin to class "C" +</span>C mixins add M2 + +<span class='nx-comment'># Invoke the method foo +</span>d1 foo +<span class='nx-comment'># result: "M1 foo: M2 foo: d1 foo: D foo: C foo: " +</span> +<span class='nx-comment'># Query the precedence order from NX via introspection +</span>d1 <span class='nx-keyword'>info</span> precedence +<span class='nx-comment'># result: "::M1 ::M2 ::D ::C ::nx::Object"</span></pre></div></div> +<div class="paragraph"><p>The example in <a href="#xmp-method-resolution2">Listing 33</a> is +an extension of the previous example. We define here two additional +classes <code>M1</code> and <code>M2</code> which are used as per-object and per-class +mixins. Both classes define the method <code>foo</code>, these methods shadow +the definitions of the intrinsic class hierarchy. Therefore an +invocation of <code>foo</code> on object <code>d1</code> causes first an invocation of +method in the per-object mixin.</p></div> +<div class="paragraph" id="xmp-method-resolution3"><div class="title">Listing 34: Method Invocation Flags</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># "d1" is created based on the definitions of the last two examples, +</span><span class='nx-comment'># the mixins "M1" and "M2" are registered. +</span><span class='nx-comment'># +</span><span class='nx-comment'># Define a public object method "bar", which calls the method +</span><span class='nx-comment'># "foo" which various invocation options: +</span><span class='nx-comment'># +</span>d1 <span class='nx-keyword'>public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {} { + <span class='nx-keyword'>puts</span> [:foo] + <span class='nx-keyword'>puts</span> [: -local foo] + <span class='nx-keyword'>puts</span> [: -intrinsic foo] + <span class='nx-keyword'>puts</span> [: -system foo] +} + +<span class='nx-comment'># Invoke the method "bar" +</span>d1 bar</pre></div></div> +<div class="paragraph"><p>In the first line of the body of method <code>bar</code>, the method <code>foo</code> is +called as usual with an implicit receiver, which defaults to the +current object (therefore, the call is equivalent to <code>d1 foo</code>). The +next three calls show how to provide flags that influence the method +resolution. The flags can be provided between the colon and the method +name. These flags are used rather seldom but can be helpful in some +situations.</p></div> +<div class="paragraph"><p>The invocation flag <code>-local</code> means that the method has to be resolved +from the same place, where the current method is defined. Since the +current method is defined as a object method, <code>foo</code> is resolved as +a object method. The effect is that the mixin definitions are +ignored. The invocation flag <code>-local</code> was already introduced int the +section about method protection, where it was used to call <em>private</em> +methods.</p></div> +<div class="paragraph"><p>The invocation flag <code>-intrinsic</code> means that the method has to be resolved +from the intrinsic definitions, meaning simply without mixins. The +effect is here the same as with the invocation flag <code>-local</code>.</p></div> +<div class="paragraph"><p>The invocation flag <code>-system</code> means that the method has to be resolved +from basic - typically predefined - classes of the object system. This +can be useful, when script overloads system methods, but still want to +call the shadowed methods from the base classes. In our case, we have +no definitions of <code>foo</code> on the base clases, therefore an error message +is returned.</p></div> +<div class="paragraph"><p>The output of <a href="#xmp-method-resolution3">Listing 34</a> is:</p></div> +<div class="listingblock"> +<div class="content"> +<pre><code> M1 foo: M2 foo: d1 foo: D foo: C foo: + d1 foo: D foo: C foo: + d1 foo: D foo: C foo: + ::d1: unable to dispatch method 'foo'</code></pre> +</div></div> +</div> +<div class="sect2"> +<h3 id="_parameters">3.7. Parameters</h3> +<div class="paragraph"><p>NX provides a generalized mechanism for passing values to either +methods (we refer to these as <em>method parameters</em>) or to objects +(these are called <em>configure parameters</em>). Both kind of parameters +might have different features, such as:</p></div> +<div class="ulist"><ul> +<li> +<p> +Positional and non-positional parameters +</p> +</li> +<li> +<p> +Required and non-required parameters +</p> +</li> +<li> +<p> +Default values for parameters +</p> +</li> +<li> +<p> +Value-checking for parameters +</p> +</li> +<li> +<p> +Multiplicity of parameters +</p> +</li> +</ul></div> +<div class="paragraph"><p>TODO: complete list above and provide a short summary of the section</p></div> +<div class="paragraph"><p>Before we discuss method and configure parameters in more detail, we +describe the parameter features in the subsequent sections based on +method parameters.</p></div> +<div class="sect3"> +<h4 id="_positional_and_non_positional_parameters">3.7.1. Positional and Non-Positional Parameters</h4> +<div class="paragraph"><p>If the position of a parameter in the list of formal arguments +(e.g. passed to a function) is significant for its meaning, this is a +<em>positional</em> parameter. If the meaning of the parameter is independent +of its position, this is a <em>non-positional</em> parameter. When we call a +method with positional parameters, the meaning of the parameters (the +association with the argument in the argument list of the method) is +determined by its position. When we call a method with non-positional +parameters, their meaning is determined via a name passed with the +argument during invocation.</p></div> +<div class="paragraph" id="xmp-posnonpos"><div class="title">Listing 35: Positional and Non-Positional Method Parameters</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o1 { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Method foo has positional parameters: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {x y} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y=$y"</span> + } + + <span class='nx-comment'># +</span> <span class='nx-comment'># Method bar has non-positional parameters: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {-x -y} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y=$y"</span> + } + + <span class='nx-comment'># +</span> <span class='nx-comment'># Method baz has non-positional and +</span> <span class='nx-comment'># positional parameters: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> baz {-x -y a} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x? [info exists x] y? [info exists y] a=$a"</span> + } +} + +<span class='nx-comment'># invoke foo (positional parameters) +</span>o1 foo 1 2 + +<span class='nx-comment'># invoke bar (non-positional parameters) +</span>o1 bar -y 3 -x 1 +o1 bar -x 1 -y 3 + +<span class='nx-comment'># invoke baz (positional and non-positional parameters) +</span>o1 baz -x 1 100 +o1 baz 200 +o1 baz -- -y</pre></div></div> +<div class="paragraph"><p>Consider the example in <a href="#xmp-posnonpos">Listing 35</a>. The method +<code>foo</code> has the argument list <code>x y</code>. This means that the first argument +is passed in an invocation like <code>o1 foo 1 2</code> to <code>x</code> (here, the value +<code>1</code>), and the second argument is passed to <code>y</code> (here the value <code>2</code>). +Method <code>bar</code> has in contrary just with non-positional arguments. Here +we pass the names of the parameter together with the values. In the +invocation <code>o1 bar -y 3 -x 1</code> the names of the parameters are prefixed +with a dash ("-"). No matter whether in which order we write the +non-positional parameters in the invocation (see line 30 and 31 in +<a href="#xmp-posnonpos">Listing 35</a>) in both cases the variables <code>x</code> +and <code>y</code> in the body of the method <code>bar</code> get the same values assigned +(<code>x</code> becomes <code>1</code>, <code>y</code> becomes <code>3</code>).</p></div> +<div class="paragraph"><p>It is certainly possible to combine positional and non-positional +arguments. Method <code>baz</code> provides two non-positional parameter (<code>-y</code> +and <code>-y</code>) and one positional parameter (namely <code>a</code>). The invocation in +line 34 passes the value of <code>1</code> to <code>x</code> and the value of <code>100</code> to <code>a</code>. +There is no value passed to <code>y</code>, therefore value of <code>y</code> will be +undefined in the body of <code>baz</code>, <code>info exists y</code> checks for the +existence of the variable <code>y</code> and returns <code>0</code>.</p></div> +<div class="paragraph"><p>The invocation in line 35 passes only a value to the positional +parameter. A more tricky case is in line 36, where we want to pass +<code>-y</code> as a value to the positional parameter <code>a</code>. The case is more +tricky since syntactically the argument parser might consider <code>-y</code> as +the name of one of the non-positional parameter. Therefore we use <code>--</code> +(double dash) to indicate the end of the block of the non-positional +parameters and therefore the value of <code>-y</code> is passed to <code>a</code>.</p></div> +</div> +<div class="sect3"> +<h4 id="_optional_and_required_parameters">3.7.2. Optional and Required Parameters</h4> +<div class="paragraph"><p>Per default positional parameters are required, and non-positional +parameters are optional (they can be left out). By using parameter +options, we can as well define positional parameters, which are +optional, and non-positional parameters, which are required.</p></div> +<div class="paragraph" id="xmp-optional-req"><div class="title">Listing 36: Optional and Required Method Parameters</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o2 { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Method foo has one required and one optional +</span> <span class='nx-comment'># positional parameter: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {x:required y:optional} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y? [info exists y]"</span> + } + + <span class='nx-comment'># +</span> <span class='nx-comment'># Method bar has one required and one optional +</span> <span class='nx-comment'># non-positional parameter: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {-x:required -y:optional} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y? [info exists y]"</span> + } +} + +<span class='nx-comment'># invoke foo (one optional positional parameter is missing) +</span>o2 foo 1</pre></div></div> +<div class="paragraph"><p>The example in <a href="#xmp-optional-req">Listing 36</a> defined method <code>foo</code> +with one required and one optional positional parameter. For this +purpose we use the parameter options <code>required</code> and <code>optional</code>. The +parameter options are separated from the parameter name by a colon. If +there are multiple parameter options, these are separated by commas +(we show this in later examples).</p></div> +<div class="paragraph"><p>The parameter definition <code>x:required</code> for method <code>foo</code> is equivalent +to <code>x</code> without any parameter options (see e.g. previous example), +since positional parameters are per default required. The invocation +in line 21 of <a href="#xmp-optional-req">Listing 36</a> will lead to an +undefined variable <code>y</code> in method <code>foo</code>, because no value us passed to +the optional parameter. Note that only trailing positional parameters might be +optional. If we would call method <code>foo</code> of <a href="#xmp-posnonpos">Listing 35</a> with only one argument, the system would raise an +exception.</p></div> +<div class="paragraph"><p>Similarly, we define method <code>bar</code> in <a href="#xmp-optional-req">Listing 36</a> with one required and one optional non-positional +parameter. The parameter definition <code>-y:optional</code> is equivalent to +<code>-y</code>, since non-positional parameter are per default optional. +However, the non-positional parameter <code>-x:required</code> is required. If we +invoke <code>bar</code> without it, the system will raise an exception.</p></div> +</div> +<div class="sect3"> +<h4 id="_default_values_for_parameters">3.7.3. Default Values for Parameters</h4> +<div class="paragraph"><p>Optional parameters might have a default value. This default value is used, +when no argument is provided for the corresponding parameter. Default values can be +specified for positional and non-positional parameters.</p></div> +<div class="paragraph" id="xmp-default-value"><div class="title">Listing 37: Method Parameters with Default Values</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o3 { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Positional parameter with default value: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {{x 1} {y 2}} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y=$y"</span> + } + + <span class='nx-comment'># +</span> <span class='nx-comment'># Non-positional parameter with default value: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {{-x 10} {-y 20}} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x y=$y"</span> + } +} + +<span class='nx-comment'># use default values +</span>o3 foo +o3 bar</pre></div></div> +<div class="paragraph"><p>In order to define a default value for a parameter, the parameter +specification must be of the form of a 2 element list, where the +second argument is the default value. See for an example in +<a href="#xmp-default-value">Listing 37</a>.</p></div> +</div> +<div class="sect3"> +<h4 id="_value_constraints">3.7.4. Value Constraints</h4> +<div class="paragraph"><p>NX provides value constraints for all kind of parameters. By +specifying value constraints a developer can restrict the permissible +values for a parameter and document the expected values in the source +code. Value checking in NX is conditional, it can be turned on or off +in general or on a per-usage level (more about this later). The same +mechanisms can be used not only for input value checking, but as well +for return value checking (we will address this point as well later).</p></div> +<div class="sect4"> +<h5 id="_built_in_value_constraints">Built-in Value Constraints</h5> +<div class="paragraph"><p>NX comes with a set of built-in value constraints, which can be +extended on the scripting level. The built-in checkers are either the +native checkers provided directly by the Next Scripting Framework (the +most efficient checkers) or the value checkers provided by Tcl through +<code>string is …</code>. The built-in checkers have as well the advantage that +they can be used also at any time during bootstrap of an object +system, at a time, when e.g. no objects or methods are defined. The +same checkers are used as well for all C-implemented primitives of NX +and the Next Scripting Framework.</p></div> +<div class="imageblock" id="img-value-checkers" style="text-align:center;"> +<div class="content"> +<img src="value-checkers.png" alt="value-checkers.png" /> +</div> +<div class="title">Figure 38. General Applicable Value Checkers in NX</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p><a href="#img-value-checkers">Figure 38</a> shows the built-in +general applicable value checkers available in NX, which can be used +for all method and configure parameters. In the next step, we show how to +use these value-checkers for checking permissible values for method +parameters. Then we will show, how to provide more detailed value +constraints.</p></div> +<div class="paragraph" id="xmp-value-check"><div class="title">Listing 39: Method Parameters with Value Constraints</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o4 { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Positional parameter with value constraints: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {x:integer o<span class='nx-keyword'>:object</span>,optional} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x o? [info exists o]"</span> + } + + <span class='nx-comment'># +</span> <span class='nx-comment'># Non-positional parameter with value constraints: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {{-x:integer 10} {-verbose:boolean false}} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x verbose=$verbose"</span> + } +} + +<span class='nx-comment'># The following invocation raises an exception, since the +</span><span class='nx-comment'># value "a" for parameter "x" is not an integer +</span>o4 foo a</pre></div></div> +<div class="paragraph"><p>Value constraints are specified as parameter options in the parameter +specifications. The parameter specification <code>x:integer</code> defines <code>x</code> as +a required positional parameter which value is constraint to an +integer. The parameter specification <code>o:object,optional</code> shows how to +combine multiple parameter options. The parameter <code>o</code> is an optional +positional parameter, its value must be an object (see +<a href="#xmp-value-check">Listing 39</a>). Value constraints are +specified exactly the same way for non-positional parameters (see +method <code>bar</code> in <a href="#xmp-value-check">Listing 39</a>).</p></div> +<div class="paragraph" id="xmp-check-parameterized"><div class="title">Listing 40: Parameterized Value Constraints</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># Create classes for Person and Project +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Person +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Project + +<span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o5 { + <span class='nx-comment'># +</span> <span class='nx-comment'># Parameterized value constraints +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> work { + -person<span class='nx-keyword'>:object</span>,type=Person + -project<span class='nx-keyword'>:object</span>,type=Project + } { + <span class='nx-comment'># ... +</span> } +} + +<span class='nx-comment'># +</span><span class='nx-comment'># Create a Person and a Project instance +</span><span class='nx-comment'># +</span>Person <span class='nx-keyword'>create</span> gustaf +Project <span class='nx-keyword'>create</span> nx + +<span class='nx-comment'># +</span><span class='nx-comment'># Use method with value constraints +</span><span class='nx-comment'># +</span>o5 work -person gustaf -project nx</pre></div></div> +<div class="paragraph"><p>The native checkers <code>object</code>, <code>class</code>, <code>metaclass</code> and <code>baseclass</code> can +be further specialized with the parameter option <code>type</code> to restrict +the permissible values to instances of certain classes. We can use for +example the native value constraint <code>object</code> either for testing +whether an argument is some object (without further constraints, as in +<a href="#xmp-default-value">Listing 37</a>, method <code>foo</code>), or we can +constrain the value further to some type (direct or indirect instance +of a class). This is shown by method <code>work</code> in +<a href="#xmp-check-parameterized">Listing 40</a> which requires +the parameter <code>-person</code> to be an instance of class <code>Person</code> and the +parameter <code>-project</code> to be an instance of class <code>Project</code>.</p></div> +</div> +<div class="sect4"> +<h5 id="_scripted_value_constraints">Scripted Value Constraints</h5> +<div class="paragraph"><p>The set of predefined value checkers can be extended by application +programs via defining methods following certain conventions. The user +defined value checkers are defined as methods of the class <code>nx::Slot</code> +or of one of its subclasses or instances. We will address such cases +in the next sections. In the following example we define two new +value checkers on class <code>nx::Slot</code>. The first value checker is called +<code>groupsize</code>, the second one is called <code>choice</code>.</p></div> +<div class="paragraph" id="xmp-user-types"><div class="title">Listing 41: Scripted Value Checker for Method Parameters</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># Value checker named "groupsize" +</span><span class='nx-comment'># +</span>::nx::Slot <span class='nx-keyword'>method</span> type=groupsize {name value} { + <span class='nx-keyword'>if</span> {<span class='nx-variable'>$value</span> < 1 || <span class='nx-variable'>$value</span> > 6} { + <span class='nx-keyword'>error</span> <span class='nx-string'>"Value '$value' of parameter $name is not between 1 and 6"</span> + } +} + +<span class='nx-comment'># +</span><span class='nx-comment'># Value checker named "choice" with extra argument +</span><span class='nx-comment'># +</span>::nx::Slot <span class='nx-keyword'>method</span> type=choice {name value arg} { + <span class='nx-keyword'>if</span> {<span class='nx-variable'>$value</span> ni [<span class='nx-keyword'>split</span> <span class='nx-variable'>$arg</span> |]} { + <span class='nx-keyword'>error</span> <span class='nx-string'>"Value '$value' of parameter $name not in permissible values $arg"</span> + } +} + +<span class='nx-comment'># +</span><span class='nx-comment'># Create an application class D +</span><span class='nx-comment'># using the new value checkers +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> D { + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> foo {a:groupsize} { + <span class='nx-comment'># ... +</span> } + <span class='nx-keyword'>:public</span> <span class='nx-keyword'>method</span> bar {a:choice,arg=red|yellow|green b:choice,arg=good|bad} { + <span class='nx-comment'># ... +</span> } +} + +D <span class='nx-keyword'>create</span> d1 + +<span class='nx-comment'># testing "groupsize"; +</span><span class='nx-comment'># the second call (with value 10) will raise an exception: +</span>d1 foo 2 +d1 foo 10 + +<span class='nx-comment'># testing "choice" +</span><span class='nx-comment'># the second call (with value pink for parameter a) +</span><span class='nx-comment'># will raise an exception: +</span>d1 bar green good +d1 bar pink bad</pre></div></div> +<div class="paragraph"><p>In order to define a checker <code>groupsize</code> a method of the name +<code>type=groupsize</code> is defined. This method receives two arguments, +<code>name</code> and <code>value</code>. The first argument is the name of the parameter +(mostly used for the error message) and the second parameter is +provided value. The value checker simply tests whether the provided +value is between 1 and 3 and raises an exception if this is not the +case (invocation in line 36 in <a href="#xmp-user-types">Listing 41</a>).</p></div> +<div class="paragraph"><p>The checker <code>groupsize</code> has the permissible values defined in its +method’s body. It is as well possible to define more generic checkers +that can be parameterized. For this parameterization, one can pass an +argument to the checker method (last argument). The checker <code>choice</code> +can be used for restricting the values to a set of predefined +constants. This set is defined in the parameter specification. The +parameter <code>a</code> of method <code>bar</code> in <a href="#xmp-user-types">Listing 41</a> +is restricted to the values <code>red</code>, <code>yellow</code> or <code>green</code>, and the +parameter <code>b</code> is restricted to <code>good</code> or <code>bad</code>. Note that the syntax +of the permissible values is solely defined by the definition of the +value checker in lines 13 to 17. The invocation in line 39 will be ok, +the invocation in line 40 will raise an exception, since <code>pink</code> is not +allowed.</p></div> +<div class="paragraph"><p>If the same checks are used in many places in the program, +defining names for the value checker will be the better choice since +it improves maintainability. For seldom used kind of checks, the +parameterized value checkers might be more convenient.</p></div> +</div> +</div> +<div class="sect3"> +<h4 id="_multiplicity">3.7.5. Multiplicity</h4> +<div class="sidebarblock"> +<div class="content"> +<div class="paragraph"><p><strong>Multiplicity</strong> is used to define whether a parameter should receive +single or multiple values.</p></div> +</div></div> +<div class="paragraph"><p>A multiplicity specification has a lower and an upper bound. A lower +bound of <code>0</code> means that the value might be empty. A lower bound of <code>1</code> +means that the parameter needs at least one value. The upper bound +might be <code>1</code> or <code>n</code> (or synonymously <code>*</code>). While the upper bound of +<code>1</code> states that at most one value has to be passed, the upper bound of +<code>n</code> says that multiple values are permitted. Other kinds of +multiplicity are currently not allowed.</p></div> +<div class="paragraph"><p>The multiplicity is written as parameter option in the parameter +specification in the form <em>lower-bound</em>..<em>upper-bound</em>. If no +multiplicity is defined the default multiplicity is <code>1..1</code>, which +means: provide exactly one (atomic) value (this was the case in the +previous examples).</p></div> +<div class="paragraph" id="xmp-multiplicity"><div class="title">Listing 42: Method Parameters with Explicit Multiplicity</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Object</span> <span class='nx-keyword'>create</span> o6 { + + <span class='nx-comment'># +</span> <span class='nx-comment'># Positional parameter with an possibly empty +</span> <span class='nx-comment'># single value +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> foo {x:integer,0..1} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x"</span> + } + + <span class='nx-comment'># +</span> <span class='nx-comment'># Positional parameter with an possibly empty +</span> <span class='nx-comment'># list of values value +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> bar {x:integer,0..n} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x"</span> + } + + <span class='nx-comment'># +</span> <span class='nx-comment'># Positional parameter with a non-empty +</span> <span class='nx-comment'># list of values +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> baz {x:integer,1..n} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"x=$x"</span> + } +}</pre></div></div> +<div class="paragraph"><p><a href="#xmp-multiplicity">Listing 42</a> contains three examples for +positional parameters with different multiplicities. Multiplicity is +often combined with value constraints. A parameter specification of +the form <code>x:integer,0..n</code> means that the parameter <code>x</code> receives a list +of integers, which might be empty. Note that the value constraints are +applied to every single element of the list.</p></div> +<div class="paragraph"><p>The parameter specification <code>x:integer,0..1</code> means that <code>x</code> might be +an integer or it might be empty. This is one style of specifying that +no explicit value is passed for a certain parameter. Another style is +to use required or optional parameters. NX does not enforce any +particular style for handling unspecified values.</p></div> +<div class="paragraph"><p>All the examples in <a href="#xmp-multiplicity">Listing 42</a> are for +single positional parameters. Certainly, multiplicity is fully +orthogonal with the other parameter features and can be used as well +for multiple parameters, non-positional parameter, default values, +etc.</p></div> +</div> +<div class="sect3"> +<h4 id="_defaults_substitution">3.7.6. Defaults substitution</h4> +<div class="paragraph"><p>Optional object and method parameters can set a default value. Recall +that default values can be specified for positional and non-positional +parameters, alike. This default value is used to define a +corresponding method-local and object variable, respectively, and to +set it to the default value. By default, the default value is taken +literally (without any substitutions). Default values can also be +preprocessed into a final value using Tcl substitution as provided by +the Tcl <code>[subst]</code> command. To control the kind of substitutions to be +performed, the parameter option <code>substdefault</code> can be provided.</p></div> +<div class="paragraph" id="substdefault"><div class="title">Listing 43: Default-value substitution using <code>substdefault</code></div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> ::D +<span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> ::C { + <span class='nx-comment'># +</span> <span class='nx-comment'># By default all substitutions (command, variable, control +</span> <span class='nx-comment'># characters) are active, when "substdefault" is used: +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:property</span> {d<span class='nx-keyword'>:object</span>,type=::D,substdefault {[::D <span class='nx-keyword'>new</span>]}} + + <span class='nx-comment'># +</span> <span class='nx-comment'># The actual property values are computed and +</span> <span class='nx-comment'># set at instantiation time. +</span> <span class='nx-comment'># +</span> <span class='nx-keyword'>:create</span> ::c +} + +::c <span class='nx-keyword'>cget</span> -d</pre></div></div> +<div class="paragraph"><p><a href="#substdefault">Listing 43</a> uses <code>substdefault</code> +to provide a default value for the property <code>d</code>. In this example, the +default value is a fresh instance of +class <code>::D</code>. When the parameter option <code>substdefault</code> is used +default, all substitution kinds of Tcl are active: command, variable, and +backslash substitution. <code>substdefault</code> can be +parametrized to include or to exclude any combination of substitution +kinds by providing a bitmask:</p></div> +<div class="ulist"><ul> +<li> +<p> +<code>substdefault=0b111</code>: all substitutions active (default) +</p> +</li> +<li> +<p> +<code>substdefault=0b100</code>: substitute backslashes only (like <code>subst -novariables -nocommands</code>) +</p> +</li> +<li> +<p> +<code>substdefault=0b010</code>: substitute variables only (like <code>subst -nobackslashes -nocommands</code>) +</p> +</li> +<li> +<p> +<code>substdefault=0b001</code>: substitute commands only (like <code>subst -nobackslashes -novariables</code>) +</p> +</li> +<li> +<p> +<code>substdefault=0b000</code>: substitute nothing (like <code>subst -nobackslashes -nocommands -novariables</code>, noop) +</p> +</li> +</ul></div> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_advanced_language_features">4. Advanced Language Features</h2> +<div class="sectionbody"> +<div class="paragraph"><p>…</p></div> +<div class="sect2"> +<h3 id="_objects_classes_and_meta_classes">4.1. Objects, Classes and Meta-Classes</h3> +<div class="paragraph"><p>…</p></div> +</div> +<div class="sect2"> +<h3 id="_resolution_order_and_next_path">4.2. Resolution Order and Next-Path</h3> +<div class="paragraph"><p>…</p></div> +</div> +<div class="sect2"> +<h3 id="_details_on_method_and_configure_parameters">4.3. Details on Method and Configure Parameters</h3> +<div class="paragraph"><p>The parameter specifications are used in NX for the following +purposes. They are used for</p></div> +<div class="ulist"><ul> +<li> +<p> +the specification of input arguments of methods and commands, for +</p> +</li> +<li> +<p> +the specification of return values of methods and commands, and for +</p> +</li> +<li> +<p> +the specification for the initialization of objects. +</p> +</li> +</ul></div> +<div class="paragraph"><p>We refer to the first two as method parameters and the last one as +configure parameters. The examples in the previous sections all parameter +specification were specifications of method parameters.</p></div> +<div class="sidebarblock"> +<div class="content"> +<div class="paragraph"><p><strong>Method parameters</strong> specify properties about permissible values passed +to methods.</p></div> +</div></div> +<div class="paragraph"><p>The method parameter specify how methods are invoked, how the +actual arguments are passed to local variables of the invoked method +and what kind of checks should be performed on these.</p></div> +<div class="sidebarblock"> +<div class="content"> +<div class="paragraph"><p><strong>Configure parameters</strong> are parameters that specify, how objects +can be parameterized upon creation.</p></div> +</div></div> +<div class="paragraph"><p>Syntactically, configure parameters and method parameters are the same, +although there are certain differences (e.g. some parameter options +are only applicable for objects parameters, the list of object +parameters is computed dynamically from the class structures, object +parameters are often used in combination with special setter methods, +etc.). Consider the following example, where we define the two +application classes <code>Person</code> and <code>Student</code> with a few properties.</p></div> +<div class="paragraph" id="xmp-object-parameters"><div class="title">Listing 44: Configure Parameters</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># +</span><span class='nx-comment'># Define a class Person with properties "name" +</span><span class='nx-comment'># and "birthday" +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Person { + <span class='nx-keyword'>:property</span> name:required + <span class='nx-keyword'>:property</span> birthday +} + +<span class='nx-comment'># +</span><span class='nx-comment'># Define a class Student as specialization of Person +</span><span class='nx-comment'># with and additional property +</span><span class='nx-comment'># +</span><span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>create</span> Student -superclass Person { + <span class='nx-keyword'>:property</span> matnr:required + <span class='nx-keyword'>:property</span> {oncampus:boolean true} +} + +<span class='nx-comment'># +</span><span class='nx-comment'># Create instances using configure parameters +</span><span class='nx-comment'># for the initialization +</span><span class='nx-comment'># +</span>Person <span class='nx-keyword'>create</span> p1 -name Bob +Student <span class='nx-keyword'>create</span> s1 -name Susan -matnr 4711 + +<span class='nx-comment'># Access property value via "cget" method +</span><span class='nx-keyword'>puts</span> <span class='nx-string'>"The name of s1 is [s1 cget -name]"</span></pre></div></div> +<div class="paragraph"><p>The class <code>Person</code> has two properties <code>name</code> and <code>birthday</code>, where the +property <code>name</code> is required, the property <code>birthday</code> is not. The +class <code>Student</code> is a subclass of <code>Person</code> with the additional required +property <code>matnr</code> and an optional property <code>oncampus</code> with the +default value <code>true</code> (see <a href="#xmp-object-parameters">Listing 44</a>). The class diagram below visualizes these +definitions.</p></div> +<div class="imageblock" id="img-configure-parameters" style="text-align:center;"> +<div class="content"> +<img src="configure-parameter.png" alt="configure-parameter.png" /> +</div> +<div class="title">Figure 45. System and Application Classes</div> +</div> +<div class="paragraph"><p></p></div> +<div class="paragraph"><p>In NX, these definitions imply that instances of the class of <code>Person</code> +have the properties <code>name</code> and <code>birthday</code> as <em>non-positional object +parameters</em>. Furthermore it implies that instances of <code>Student</code> will +have the configure parameters of <code>Person</code> augmented with the object +parameters from <code>Student</code> (namely <code>matnr</code> and <code>oncampus</code>). Based on +these configure parameters, we can create a <code>Person</code> named <code>Bob</code> and a +<code>Student</code> named <code>Susan</code> with the matriculation number <code>4711</code> (see line +23 and 24 in <<xmp-object-parameters, +instance variables <code>name</code>, <code>matnr</code> and <code>oncampus</code> (the latter is +initialized with the default value).</p></div> +<div class="sect3"> +<h4 id="_configure_parameters_available_for_all_nx_objects">4.3.1. Configure Parameters available for all NX Objects</h4> +<div class="paragraph"><p>The configure parameters are not limited to the application defined +properties, also NX provides some predefined definitions. Since +<code>Person</code> is a subclass of <code>nx::Object</code> also the configure parameters of +<code>nx::Object</code> are inherited. In the introductory stack example, we used +<code>-mixins</code> applied to an object to denote per-object mixins (see +<a href="#xmp-using-class-safety">Listing 8</a>). Since <code>mixins</code> +is defined as a parameter on <code>nx::Object</code> it can be used as an object +parameter <code>-mixins</code> for all objects in NX. To put it in other words, +every object can be configured to have per-object mixins. If we would +remove this definition, this feature would be removed as well.</p></div> +<div class="paragraph"><p>As shown in the introductory examples, every object can be configured +via a scripted initialization block (the optional scripted block +specified at object creation as last argument; see +<a href="#xmp-object-stack">Listing 5</a> or +<a href="#xmp-object-integer-stack">Listing 12</a>). The +scripted block and its meaning are as well defined by the means of +configure parameters. However, this configure parameter is positional (last +argument) and optional (it can be omitted). The following listing shows +the configure parameters of <code>Person p1</code> and <code>Student s1</code>.</p></div> +<div class="paragraph" id="xmp-object-parameter-list"><div class="title">Listing 46: Computed Actual Configure Parameter</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>Configure parameters <span class='nx-keyword'>for</span> Person p1: + Command: + p1 <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>configure</span> + Result: + -name <span class='nx-placeholder'>/value/</span> ?-birthday <span class='nx-placeholder'>/value/</span>? ?-object-mixins /mixinreg .../<span class='nx-placeholder'>? + ?</span>-class /<span class='nx-keyword'>class</span>/? ?-object-filters /filterreg .../? ?/__initblock/? + +Configure parameter <span class='nx-keyword'>for</span> Student s1: + Command: + s1 <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>configure</span> + Result: + ?-oncampus <span class='nx-placeholder'>/boolean/</span>? -matnr <span class='nx-placeholder'>/value/</span> -name <span class='nx-placeholder'>/value/</span> + ?-birthday <span class='nx-placeholder'>/value/</span>? ?-object-mixins /mixinreg .../? ?-class /<span class='nx-keyword'>class</span>/<span class='nx-placeholder'>? + ?</span>-object-filters /filterreg .../? ?/__initblock/?</pre></div></div> +<div class="paragraph"><p>The given parameter show, how (a) objects can be configured +at runtime or (b) how new instances can be configured +at creation time via the <code>new</code> or <code>create</code> methods. +Introspection can be used to obtain the configuration +parameters from an object via +<code>p1 info lookup parameters configure</code> +(returning the configure parameters currently applicable for +<code>configure</code> or <code>cget</code>) or from a class +<code>Person info lookup parameters create</code> on a class +(returning the configure parameters applicable when an object +of this class is created)</p></div> +<div class="paragraph"><p>The listed configure parameter types <code>mixinreg</code> and +<code>filterreg</code> are for converting definitions of filters and mixins. The +last value <code>__initblock</code> says that the content of this variable +will be executed in the context of the object being created (before +the constructor <code>init</code> is called). More about the configure parameter +types later.</p></div> +</div> +<div class="sect3"> +<h4 id="_configure_parameters_available_for_all_nx_classes">4.3.2. Configure Parameters available for all NX Classes</h4> +<div class="paragraph"><p>Since classes are certain kind of objects, classes are parameterized +in the same way as objects. A typical parameter for a class definition +is the relation of the class to its superclass.In our example, we have +specified, that <code>Student</code> has <code>Person</code> as superclass via the +non-positional configure parameter <code>-superclass</code>. If no superclass is +specified for a class, the default superclass is +<code>nx::Object</code>. Therefore <code>nx::Object</code> is the default value for the +parameter <code>superclass</code>.</p></div> +<div class="paragraph"><p>Another frequently used parameter for classes is <code>-mixins</code> to denote +per-class mixins (see e.g. the introductory Stack example in +<a href="#xmp-class-safestack">Listing 10</a>), which is defined in +the same way.</p></div> +<div class="paragraph"><p>Since <code>Student</code> is an instance of the meta-class <code>nx::Class</code> it +inherits the configure parameters from <code>nx::Class</code> (see class diagram +<a href="#img-configure-parameters">Figure 45</a>). +Therefore, one can use e.g. <code>-superclass</code> in the definition of classes.</p></div> +<div class="paragraph"><p>Since <code>nx::Class</code> is a subclass of <code>nx::Object</code>, the meta-class +<code>nx::Class</code> inherits the parameter definitions from the most general +class <code>nx::Object</code>. Therefore, every class might as well be configured +with a scripted initialization block the same way as objects can be +configured. We used actually this scripted initialization block in +most examples for defining the methods of the class. The following +listing shows (simplified) the parameters applicable for <code>Class +Student</code>.</p></div> +<div class="paragraph" id="xmp-class-parameter-list"><div class="title">Listing 47: Parameters for Classes</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>Configure parameter <span class='nx-keyword'>for</span> <span class='nx-keyword'>class</span> <span class='nx-keyword'>nx::Class</span> + Command: + <span class='nx-keyword'>nx::Class</span> <span class='nx-keyword'>info</span> <span class='nx-keyword'>lookup</span> syntax <span class='nx-keyword'>configure</span> + Result: + ?-superclass /<span class='nx-keyword'>class</span> .../? ?-mixins /mixinreg .../<span class='nx-placeholder'>? + ?</span>-filters /filterreg .../? ?-object-mixins /mixinreg .../<span class='nx-placeholder'>? + ?</span>-class /<span class='nx-keyword'>class</span>/? ?-object-filters /filterreg .../? ?/__initblock/?</pre></div></div> +</div> +<div class="sect3"> +<h4 id="_user_defined_parameter_types">4.3.3. User defined Parameter Types</h4> +<div class="paragraph"><p>More detailed definition of the configure parameter types comes here.</p></div> +</div> +<div class="sect3"> +<h4 id="_slot_classes_and_slot_objects">4.3.4. Slot Classes and Slot Objects</h4> +<div class="paragraph"><p>In one of the previous sections, we defined scripted (application +defined) checker methods on a class named <code>nx::Slot</code>. In general NX +offers the possibility to define value checkers not only for all +usages of parameters but as well differently for method parameters or +configure parameters</p></div> +<div class="imageblock" id="img-slots" style="text-align:center;"> +<div class="content"> +<img src="slots.png" alt="slots.png" /> +</div> +<div class="title">Figure 48. Slot Classes and Objects</div> +</div> +<div class="paragraph"><p></p></div> +</div> +<div class="sect3"> +<h4 id="_attribute_slots">4.3.5. Attribute Slots</h4> +<div class="paragraph"><p>Still Missing</p></div> +<div class="ulist"><ul> +<li> +<p> +return value checking +</p> +</li> +<li> +<p> +switch +</p> +</li> +<li> +<p> +initcmd … +</p> +</li> +<li> +<p> +subst rules +</p> +</li> +<li> +<p> +converter +</p> +</li> +<li> +<p> +incremental slots +</p> +</li> +</ul></div> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_miscellaneous">5. Miscellaneous</h2> +<div class="sectionbody"> +<div class="paragraph"><p>…</p></div> +<div class="sect2"> +<h3 id="_profiling">5.1. Profiling</h3> +<div class="paragraph"><p>…</p></div> +</div> +<div class="sect2"> +<h3 id="_unknown_handlers">5.2. Unknown Handlers</h3> +<div class="paragraph"><p>NX provides two kinds of unknown handlers:</p></div> +<div class="ulist"><ul> +<li> +<p> +Unknown handlers for methods +</p> +</li> +<li> +<p> +Unknown handlers for objects and classes +</p> +</li> +</ul></div> +<div class="sect3"> +<h4 id="_unknown_handlers_for_methods">5.2.1. Unknown Handlers for Methods</h4> +<div class="paragraph"><p>Object and classes might be equipped +with a method <code>unknown</code> which is called in cases, where an unknown +method is called. The method unknown receives as first argument the +called method followed by the provided arguments</p></div> +<div class="paragraph" id="xmp-unknown-method"><div class="title">Listing 49: Unknown Method Handler</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nx::Object <span class='nx-keyword'>create</span> o { + <span class='nx-keyword'>:object</span> <span class='nx-keyword'>method</span> <span class='nx-keyword'>unknown</span> {called_method args} { + <span class='nx-keyword'>puts</span> <span class='nx-string'>"Unknown method '$called_method' called"</span> + } +} + +<span class='nx-comment'># Invoke an unknown method for object o: +</span>o foo 1 2 3 + +<span class='nx-comment'># Output will be: "Unknown method 'foo' called"</span></pre></div></div> +<div class="paragraph"><p>Without any provision of an unknown method handler, an error will be +raised, when an unknown method is called.</p></div> +</div> +<div class="sect3"> +<h4 id="_unknown_handlers_for_objects_and_classes">5.2.2. Unknown Handlers for Objects and Classes</h4> +<div class="paragraph"><p>The next scripting framework provides in addition to unknown method +handlers also a means to dynamically create objects and classes, when +these are referenced. This happens e.g. when superclasses, mixins, or +parent objects are referenced. This mechanism can be used to implement +e.g. lazy loading of these classes. Nsf allows one to register multiple +unknown handlers, each identified by a key (a unique name, different +from the keys of other unknown handlers).</p></div> +<div class="paragraph" id="xmp-unknown-class"><div class="title">Listing 50: Unknown Class Handler</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'>::nx::Class <span class='nx-keyword'>public</span> <span class='nx-keyword'>object</span> <span class='nx-keyword'>method</span> __unknown {name} { + <span class='nx-comment'># A very simple unknown handler, showing just how +</span> <span class='nx-comment'># the mechanism works. +</span> <span class='nx-keyword'>puts</span> <span class='nx-string'>"***** __unknown called with <$name>"</span> + ::nx::Class <span class='nx-keyword'>create</span> <span class='nx-variable'>$name</span> +} + +<span class='nx-comment'># Register an unknown handler as a method of ::nx::Class +</span>::nsf::object::unknown::add nx {::nx::Class __unknown} + +::nx::Object <span class='nx-keyword'>create</span> o { + <span class='nx-comment'># The class M is unknown at this point +</span> + <span class='nx-keyword'>:object</span> mixins add M + <span class='nx-comment'># The line above has triggered the unknown class handler, +</span> <span class='nx-comment'># class M is now defined +</span> + <span class='nx-keyword'>puts</span> [<span class='nx-keyword'>:info</span> <span class='nx-keyword'>object</span> mixins] + <span class='nx-comment'># The output will be: +</span> <span class='nx-comment'># ***** __unknown called with <::M> +</span> <span class='nx-comment'># ::M +</span>}</pre></div></div> +<div class="paragraph"><p>The Next Scripting Framework allows one to add, query, delete and list unknown handlers.</p></div> +<div class="paragraph" id="xmp-unknown-registration"><div class="title">Listing 51: Unknown Handler registration</div><p></p></div> +<div class="listingblock"> +<div class="content"><style type='text/css'> +.nx {color: #000000; font-weight: normal; font-style: normal; padding-left: 10px} +table.nx {border-collapse: collapse; border-spacing: 3px;} +.nx-linenr {border-right: 1px solid #DDDDDD;padding-right: 5px; color: #2B547D;font-style: italic;} +.nx-string {color: #779977; font-weight: normal; font-style: italic;} +.nx-comment {color: #717ab3; font-weight: normal; font-style: italic;} +.nx-keyword {color: #7f0055; font-weight: normal; font-style: normal;} +.nx-placeholder {color: #AF663F; font-weight: normal; font-style: italic;} +.nx-variable {color: #AF663F; font-weight: normal; font-style: normal;} +</style> +<pre class='nx'><span class='nx-comment'># Interface for unknown handlers: +</span><span class='nx-comment'># nsf::object::unknown::add /key/ /handler/ +</span><span class='nx-comment'># nsf::object::unknown::get /key/ +</span><span class='nx-comment'># nsf::object::unknown::delete /key/ +</span><span class='nx-comment'># nsf::object::unknown::keys</span></pre></div></div> +<div class="ulist bibliography"><div class="title">References</div><ul> +<li> +<p> +<a id="Zdun"></a> U. Zdun, M. Strembeck, G. Neumann: + Object-Based and Class-Based Composition of Transitive Mixins, + Information and Software Technology, 49(8) 2007 . +</p> +</li> +<li> +<p> +<a id="Neumann and Zdun 1999a"></a> G. Neumann and U. Zdun: Filters as a + language support for design patterns in object-oriented scripting + languages. In Proceedings of COOTS’99, 5th Conference on + Object-Oriented Technologies and Systems, San Diego, May 1999. +</p> +</li> +<li> +<p> +<a id="Neumann and Zdun 1999b"></a> G. Neumann and U. Zdun: Implementing + object-specific design patterns using per-object mixins. In Proc. of + NOSA`99, Second Nordic Workshop on Software Architecture, Ronneby, + Sweden, August 1999. +</p> +</li> +<li> +<p> +<a id="Neumann and Zdun 1999c"></a> G. Neumann and U. Zdun: Enhancing + object-based system composition through per-object mixins. In + Proceedings of Asia-Pacific Software Engineering Conference (APSEC), + Takamatsu, Japan, December 1999. +</p> +</li> +<li> +<p> +<a id="Neumann and Zdun 2000a"></a> G. Neumann and U. Zdun: XOTCL, an + object-oriented scripting language. In Proceedings of Tcl2k: The + 7th USENIX Tcl/Tk Conference, Austin, Texas, February 2000. +</p> +</li> +<li> +<p> +<a id="Neumann and Zdun 2000b"></a> G. Neumann and U. Zdun: Towards the Usage + of Dynamic Object Aggregations as a Form of Composition In: + Proceedings of Symposium of Applied Computing (SAC’00), Como, + Italy, Mar 19-21, 2000. +</p> +</li> +<li> +<p> +<a id="Neumann and Sobernig 2009"></a> G. Neumann, S. Sobernig: XOTcl 2.0 - A + Ten-Year Retrospective and Outlook, in: Proceedings of the Sixteenth + Annual Tcl/Tk Conference, Portland, Oregon, October, 2009. +</p> +</li> +<li> +<p> +<a id="Ousterhout 1990"></a> J. K. Ousterhout: Tcl: An embeddable command + language. In Proc. of the 1990 Winter USENIX Conference, January 1990. +</p> +</li> +<li> +<p> +<a id="Ousterhout 1998"></a> J. K. Ousterhout: Scripting: Higher Level + Programming for the 21st Century, IEEE Computer 31(3), March 1998. +</p> +</li> +<li> +<p> +<a id="Wetherall and Lindblad 1995"></a> D. Wetherall and C. J. Lindblad: Extending Tcl for + Dynamic Object-Oriented Programming. Proc. of the Tcl/Tk Workshop '95, + July 1995. +</p> +</li> +</ul></div> +</div> +</div> +</div> +</div> +</div> +<div id="footnotes"><hr /></div> +<div id="footer"> +<div id="footer-text"> +Version 2.2.0<br /> +Last updated 2019-04-12 16:25:08 CEST +</div> +</div> +</body> +</html> Index: library/xotcl/apps/comm/link-checker.xotcl =================================================================== diff -u -r9a0b8bb0992be0561d8187c275fc1d9b7e0bbcd0 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- library/xotcl/apps/comm/link-checker.xotcl (.../link-checker.xotcl) (revision 9a0b8bb0992be0561d8187c275fc1d9b7e0bbcd0) +++ library/xotcl/apps/comm/link-checker.xotcl (.../link-checker.xotcl) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -15,7 +15,7 @@ <tr><td>-local <td> A string match pattern to decide which url should be treated as local e.g. -local *wu-wien.ac.at/* - Per default the locality filter ist set + Per default the locality filter is set to the name of the host followed by '/*'</td></tr> <tr><td>-restrict <td> 0 or 1, sets the locality filter to the subtree implied by the URL</td></tr> Index: library/xotcl/doc/Announce-1.6.0 =================================================================== diff -u -rb5c493afe905b1bafc17697ed3ce01d1662c77b3 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- library/xotcl/doc/Announce-1.6.0 (.../Announce-1.6.0) (revision b5c493afe905b1bafc17697ed3ce01d1662c77b3) +++ library/xotcl/doc/Announce-1.6.0 (.../Announce-1.6.0) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -58,7 +58,7 @@ will be marked as deprecated in the near future. Please note that the behavior of the match pattern has - changed and is therefor not completely compatible with + changed and is therefore not completely compatible with prior versions. * New info subcommands: Index: library/xotcl/doc/tutorial.html =================================================================== diff -u -rcfb3421c9ebcc80ee2b48544717135b56c7c9946 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- library/xotcl/doc/tutorial.html (.../tutorial.html) (revision cfb3421c9ebcc80ee2b48544717135b56c7c9946) +++ library/xotcl/doc/tutorial.html (.../tutorial.html) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -861,7 +861,7 @@ <P>Initially XOTcl offers two new commands: <tt>Object</tt> and <tt>Class</tt>. They represent hooks to the features of the language. This section discusses both of them in detail and shows how they -function in the context of XOTcl. Note, that even if most of this is +function in the context of XOTcl. Note that even if most of this is compatible to OTcl, a few changes occur. For this reason, this section is no introduction to plain OTcl. The <tt>Object</tt> command provides access to the <tt>Object</tt> class, which holds the common @@ -1024,7 +1024,7 @@ </P> <LI><P STYLE="margin-bottom: 0in"><tt>self class</tt>: the self command with the argument <tt>class</tt> returns the name of the - class, which holds the currently executing instproc. Note, that this + class, which holds the currently executing instproc. Note that this may be different to the class of the current object. If it is called from a proc it returns an empty string. </P> @@ -1041,7 +1041,7 @@ <tt>my</tt> <tt>set</tt> persons($name) [<tt>clock</tt> seconds] } </pre><P> -<P>Note, that there is a difference to the realization of these +<P>Note that there is a difference to the realization of these object information to OTcl. XOTcl uses commands in order to make XOTcl-methods compatible to Tcl-procedures and accessible via namespace-paths. OTcl uses the three variables <tt>self</tt>, <tt>class</tt> @@ -1544,8 +1544,8 @@ leaves it's instances with the class <tt>Object</tt>. </P> <P>So all empty class- and superclass-relationships are automatically -reset to <tt>Object</tt>. Note, that this are differences to OTcl, -where the destruction of an class destroys all instances and an empty +reset to <tt>Object</tt>. Note that this are differences to OTcl, +where the destruction of a class destroys all instances and an empty super-class list remains empty. </P> <H3><A NAME="class_method_chaining"></A>Method Chaining @@ -1622,7 +1622,7 @@ four instance variables <tt>cookName</tt>, <tt>roomNumber</tt>, <tt>doorPosition</tt> and <tt>stoveType</tt> set up with default values in this order (since this is the order of the classes in the -next-path). Note, that the order is important, because one missing +next-path). Note that the order is important, because one missing next call, in one of the <tt>init</tt> methods, means that succeeding <tt>init</tt> methods will not be executed. This mechanism functions equally on all kinds of instprocs, not only on constructors. @@ -1754,8 +1754,7 @@ predefined meta-class <tt>Class</tt>, or by adding an instmixin class (see <A HREF="per-class-mixins">below</A>) containing <tt>Class</tt> to the precedence chain of the class. By defining <tt>Object -instmixin Class</tt> one can even change the object system of XOTcl in -in a way such that every created Object is a meta-class. +instmixin Class</tt> one can even change the object system of XOTclin a way such that every created Object is a meta-class. </P> <P>Since the concept of a meta-class are sometimes confusing to people of a background of some other programming @@ -1970,7 +1969,7 @@ <tt>doInitializations</tt>. </p> <p> - Note, that <tt>recreate</tt> is not called, when a someone tries + Note that <tt>recreate</tt> is not called, when a someone tries to recreate a class as an object or an object as a class. In these cases, <tt>destroy</tt> + <tt>create</tt> are used. <pre CLASS="code"> @@ -2320,7 +2319,7 @@ <P>All messages to a filtered object must go through the filter before they reach their destination object. A simple example would be a sole filter on the class of the object. To define such a filter two steps -are necessary. Firstly an filter method has to be defined, then the +are necessary. Firstly a filter method has to be defined, then the filter has to be registered. The filter method consists of three parts which are all optional. A filter method has the following form: </P> @@ -2812,13 +2811,13 @@ </P> The inverse operation of <tt>info mixin</tt> is <tt>mixinof</tt> finds -out, into which objects an per-object mixin class is mixed into. +out, into which objects a per-object mixin class is mixed into. <pre CLASS="code"> <em>clsName</em> <tt>info</tt> mixinof <em>?pattern?</em> </pre> -<P> Note, that the constructors (init methods) of per-object mixins (and per-class mixins) +<P> Note that the constructors (init methods) of per-object mixins (and per-class mixins) are only called, if the mixin is registered already during object initialization (when <tt>init</tt> is called). For per-object mixins, one can achieve the initialization of a mixin via an idiom like @@ -2827,7 +2826,7 @@ </pre> that registers the mixin before <tt>init</tt> is called. When a mixin is registered after object creation and it needs initializations, it is necessary to -define special methods for this. Note, that the behavior described +define special methods for this. Note that the behavior described here is introduced in version 0.84 to ensure consistent behavior of intrinsic classes, per-object and per-class mixins, and to achieve predictable behavior for dynamic registration for all kind of mixins, @@ -2897,7 +2896,7 @@ <em>className</em> <tt>instmixin</tt> <em>mixinList</em> </pre> The inverse operation of <tt>info inmixin</tt> is <tt>instmixinof</tt> finds -out, into which objects an per-object mixin class is mixed into. +out, into which objects a per-object mixin class is mixed into. <pre CLASS="code"> <em>className</em> <tt>info</tt> instmixinof <em>?-closure? ?pattern?</em> @@ -2962,7 +2961,7 @@ </P> <p>Per-class mixins are applied transitively. That means the per-class -mixin A of a per-class mixin B is also applied for an object in in B's +mixin A of a per-class mixin B is also applied for an objectin B's scope. This is exactly the same as how superclasses are applied for instances. Consider the following example</p> @@ -3244,7 +3243,7 @@ </CENTER> </P> <P> -Note, that the list of possible actions can be +Note that the list of possible actions can be extended by extending the class <tt>::xotcl::Relations</tt>. </P> @@ -3257,9 +3256,9 @@ accessible within their scope. But the interceptors are mechanisms, which cover more then their sole scope. The meaningful usage of the meta-programming abilities often requires to go further and to get -information from the caller's and the callee's scope (e.g for +information from the caller's and the callee's scope (e.g. for delegation decisions). Therefore, we introduced rich call-stack -information for the interceptors. Note, that these are also available +information for the interceptors. Note that these are also available for ordinary methods, but the "called..." info options return empty strings. </P> @@ -3383,7 +3382,7 @@ </CENTER> </P> <p><br></p> -<P>Note, that three options with the prefix <tt>calling</tt> +<P>Note that three options with the prefix <tt>calling</tt> represent the values of <tt>self</tt>, <tt>self proc</tt>, and <tt>self class</tt> in the scope where the original call was invoked. In the following section we will show a simple program in which all of the @@ -4770,7 +4769,7 @@ <H2><A NAME="autonames">Automatic Name Creation</A> </H2> The XOTcl <FONT SIZE=2>autoname</FONT> -instance method provides an simple way to take the task of +instance method provides a simple way to take the task of automatically creating names out of the responsibility of the programmer. The example below shows how to create on each invocation of method <FONT SIZE=2>new</FONT> an agent with a fresh name Index: library/xotcl/library/comm/Httpd.xotcl =================================================================== diff -u -r6b093438fe4e4b2aae05f6662de2346980a0a111 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- library/xotcl/library/comm/Httpd.xotcl (.../Httpd.xotcl) (revision 6b093438fe4e4b2aae05f6662de2346980a0a111) +++ library/xotcl/library/comm/Httpd.xotcl (.../Httpd.xotcl) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -612,7 +612,7 @@ Httpd::Responder::Wrk instproc respond {} { my instvar fileName method resourceName hasFormData [my info parent] instvar respondpatterns - ### auch das ist ein kandidat fuer eine chain of responsibility + ### auch das ist ein Kandidat fuer eine Chain-of responsibility foreach {pattern action} $respondpatterns { if {[regexp $pattern "$method $resourceName $hasFormData"]} { my $action @@ -752,7 +752,7 @@ # (credentials) ok sind. Hier habe ich probleme auf die sachen, # die der worker gesendet (bspw. nonce) hat zu kommen. Ich # weiß, man kann mit [my info children] daran kommen. Aber, - # was ist, wenn man mehrere Worker hat? + # was is, wenn man mehrere Worker hat? ## Fredj, das sollte kein Problem sein: das credentialsNotOk wird ## vom aktuellen worker (respond) aufgerufen. man kann dem *NotOk Index: library/xotcl/library/lib/trace.xotcl =================================================================== diff -u -r073177c8b1304443107efeeb0c334e9477346778 -r2352fb1a509bd00ec49c9677798caad6bfec4d71 --- library/xotcl/library/lib/trace.xotcl (.../trace.xotcl) (revision 073177c8b1304443107efeeb0c334e9477346778) +++ library/xotcl/library/lib/trace.xotcl (.../trace.xotcl) (revision 2352fb1a509bd00ec49c9677798caad6bfec4d71) @@ -46,7 +46,7 @@ @ Object instproc statFilter {} { Description {Experimental statistics filter} } - @ Object instproc showVars {args "ist of variables"} { + @ Object instproc showVars {args "list of variables"} { Description {Show the values of the specified variables (or of all variables) of an object on stderr.} }