Tcl Source Code

Artifact [5e23e43f19]
Login

Artifact 5e23e43f1954fc460cab6fb30aea8e871d8d0d8c:

Attachment "43.patch" to ticket [1118559fff] added by davidw 2005-02-08 21:17:49.
Index: Tcl43.html
===================================================================
RCS file: /cvsroot/tcl/tcltutorial/html/Tcl43.html,v
retrieving revision 1.3
diff -u -w -r1.3 Tcl43.html
--- Tcl43.html	5 Jan 2005 14:25:16 -0000	1.3
+++ Tcl43.html	4 Feb 2005 17:58:35 -0000
@@ -1,23 +1,20 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<html>
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html 
+     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+	 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
-
 <title>Child interpreters</title>
-    <link rel="stylesheet" href="style.css">
+	<link rel="stylesheet" href="style.css" />
 </head>
 <body>
-
 <h2 class="title">Child interpreters</h2>
-<div class="nav"><a href="Tcl42.html">Previous lesson</a> | <a href="tcltutorial.html">Index</a></div>
-
-
-
-
-
-
-
 
+<div class="nav">
+	<a href="Tcl42.html">Previous lesson</a> | <a href="tcltutorial.html">Index</a>
+</div>
 
+<p>
 For most applications, a single interpreter and subroutines are
 quite sufficient.  However, if you are building a client-server
 system (for example) you may need to have several interpreters
@@ -25,66 +22,86 @@
 can do this with state variables, naming conventions, or swapping
 state to and from disk, but that gets messy.
 </p><p>
-The <B>interp</B> command creates new child interpreters within an
-existing interpreter.  The child interpreters can have their own sets of
-variables and files, or they can be given access to items in the 
-parent interpreter.
-</p><p>
-If the child is created with the <B>-safe</B> option, it will not
-be able to access the file system, or otherwise damage your system.
-This feature allows a script to evaluate code from an unknown (and untrusted)
-site.
+	The <code class="command">interp</code> command creates new child 
+	interpreters within an existing interpreter.  The child interpreters 
+	can have their own sets of variables, commands and open files, or they 
+	can be given access to items in the parent interpreter.
+</p><p>
+	If the child is created with the <code class="arg">-safe</code> option,
+	it will not be able to access the file system, or otherwise damage 
+	your system.  This feature allows a script to evaluate code from 
+	an unknown (and untrusted) source.
 </p><p>
 The names of child interpreters are a hierarchical list.  If interpreter 
-<B>foo</B> is a child of interpreter <B>bar</B>, then it can be 
-accessed from the toplevel interpreter as <code class="keyword">{bar foo}</code>.
+	<code class="keyword">foo</code> is a child of interpreter <code class="keyword">bar</code>, 
+	then it can be accessed from the toplevel interpreter as 
+	<code class="keyword">{bar foo}</code>.
 </p><p>
 The primary interpreter (what you get when you type tclsh) is the
-empty list {}.
+	empty list <code class="keyword">{}</code>.
 </p><p>
-The <B>interp</B> command has several subcommands and options.  A
-critical subset is:
-
-<DL>
-<DT><B>interp</B> create <I>?-safe? ?name?</I>
-<DD>Creates a new interpreter and returns the name.  If the 
-<I>-safe</I> option is used, the new interpreter will be unable to
-access certain dangerous system facilities.
-<DT><B>interp</B> delete <I>name</I>
-<DD> Deletes the named child interpreter.
-<DT><B>interp</B> eval <I>args</I>
-<DD> This is similar to the regular <B>eval</B> command, except that
-it evaluates the script in the child interpreter instead of the
-primary interpreter.  The <B>interp eval</B> command  concatenates
+	The <code class="command">interp</code> command has several 
+	subcommands and options.  A critical subset is:
+</p>
+
+<dl>
+	<dt>
+		<code class="command">interp create</code>
+		<code class="optarg">-safe</code>
+		<code class="optarg">name</code>
+	</dt><dd>
+		Creates a new interpreter and returns the name.  If the 
+		<code class="optarg">-safe</code> option is used, the 
+		new interpreter will be unable to access certain dangerous 
+		system facilities.
+	</dd><dt>
+		<code class="command">interp delete</code> <code class="optarg">name</code>
+	</dt><dd>
+		Deletes the named child interpreter.
+	</dd><dt>
+		<code class="command">interp eval</code> <code class="optarg">args</code>
+	</dt><dd>
+		This is similar to the regular <code class="command">eval</code>
+		command, except that it evaluates the script in the child 
+		interpreter instead of the primary interpreter.  
+		The <code class="command">interp eval</code> command concatenates
 the args into a string, and ships that line to the child interpreter
 to evaluate.
-<DT><B>interp</B> alias <I>srcPath srcCmd targetPath targetCmd ?arg arg?</I>
-<DD> The <B>interp alias</B> command allows a script to share 
-procedures between child interpreters or between a child and the primary 
-interpreter.
-</DL>
-</p><p>
+	</dd><dt>
+	<code class="command">interp alias</code>
+	<code class="reqarg">srcPath srcCmd targetPath targetCmd</code>
+	<code class="optarg">arg arg</code>
+	</dt><dd>
+		The <code class="command">interp alias</code> command allows 
+		a script to share procedures between child interpreters or 
+		between a child and the primary interpreter.
+	</dd>
+</dl>
+
+<p>
 Note that slave interpreters have a separate state and namespace, but
-do <B>not</B> have separate event loops.  These are not threads, and they
+	do <em>not</em> have separate event loops.  These are not threads, and they
 will not execute independently.  If one slave interpreter gets stopped
 by a blocking I/O request, for instance, no other interpreters will be
-prcessed until it has unblocked.  
+	processed until it has unblocked.  
 </p><p>
 The example below shows two child interpreters being created under
-the primary interpreter {}.  Each of these interpreters is given a variable
+	the primary interpreter <code class="keyword">{}</code>.
+	Each of these interpreters is given a variable
 <code class="keyword">name</code> which contains the name of the interpreter.
 </p><p>
 Note that the alias command causes the procedure to be evaluated in the
 interpreter in which the procedure was defined, not the interpreter
 in which it was evaluated.  If you need a procedure to exist within
-an interpreter, you must <code class="keyword"> interp eval</code> a <code class="keyword">proc</code>
-command within that interpreter.  If you want an interpreter to be
-able to call back to the primary interpreter (or other interpreter)
-you can use the <code class="keyword"> interp alias</code> command.
-
-		    <hr>
+	an interpreter, you must <code class="command">interp eval</code> a
+	<code class="keyword">proc</code> command within that interpreter. 
+	If you want an interpreter to be able to call back to the primary 
+	interpreter (or other interpreter) you can use the 
+	<code class="command"> interp alias</code> command.
+</p>
+<hr />
 		    <h3>Example</h3>
-		    <pre class="example">
+<p><code class="example">
 set i1 [interp create firstChild]
 set i2 [interp create secondChild]
 
@@ -127,7 +144,10 @@
 puts "firstChild reports [interp eval $i1 rtnName]"
 
 
-</pre>
-<div class="nav"><a href="Tcl42.html">Previous lesson</a> | <a href="tcltutorial.html">Index</a></div>
+</code></p>
+
+<div class="nav">
+<a href="Tcl42.html">Previous lesson</a> | <a href="tcltutorial.html">Index</a>
+</div>
 
 </body></html>