<ppdoc>
<copyright>
    Copyright (c) 2001 by Addison Wesley Longman.  This
    material may be distributed only subject to the terms and
    conditions set forth in the Open Publication License, v1.0 or
    later (the latest version is presently available at
    http://www.opencontent.org/openpub/).
</copyright>

<chapter  ref="xref-000001" name="Interactive Ruby Shell">
<p/>
Back on page 124 we introduced irb, a Ruby module that lets you 
enter Ruby programs interactively and see the results
immediately. This appendix goes into more detail on using and
customizing irb.
<p/>
<section>Command Line</section>
<p/>
<tt>irb</tt> is run from the command line.
<p/>
<syntax>
irb <opt><nt>irb-options</nt></opt> <opt><nt>ruby_script</nt></opt> <opt><nt>options</nt></opt>
</syntax>
<p/>
The command-line options for irb are listed in Table
B.1 on page 518. Typically, you'll run irb with no options, but
if you want to run a script and watch the blow-by-blow description as
it runs, you can provide the name of the Ruby script and any options
for that script.
<figure type="table">
<caption>irb command-line options</caption>
<table>
<th>
  <td><b>Option</b></td>
  <td><b>Description</b></td>
</th>
<tr>
  <td><tt>-f</tt></td>
  <td>Suppress reading <tt>~/.irbrc</tt>.</td>
</tr>
<tr>
  <td><tt>-m</tt></td>
  <td>Math mode (fraction and matrix 
                          support is available).</td>
</tr>
<tr>
  <td><tt>-d</tt></td>
  <td>Set <tt>$DEBUG</tt>  to true (same as
                          ``<tt>ruby -d</tt>'').</td>
</tr>
<tr>
  <td><tt>-r load-module</tt></td>
  <td>Same as ``<tt>ruby -r</tt>''.</td>
</tr>
<tr>
  <td><tt>--inspect</tt></td>
  <td>Use ``inspect'' for output (the default, unless
                          in math mode).</td>
</tr>
<tr>
  <td><tt>--noinspect</tt></td>
  <td>Do not use inspect for output.</td>
</tr>
<tr>
  <td><tt>--readline</tt></td>
  <td>Use <tt>Readline</tt> extension module.</td>
</tr>
<tr>
  <td><tt>--noreadline</tt></td>
  <td>Do not use <tt>Readline</tt> extension module.</td>
</tr>
<tr>
  <td><tt>--prompt</tt> <em>prompt-mode</em></td>
  <td>Switch prompt mode. Predefined
                         prompt modes are ``default'', ``simple'', 
                         ``xmp'', and ``inf-ruby''.</td>
</tr>
<tr>
  <td><tt>--prompt-mode</tt> <em>prompt-mode</em></td>
  <td>Same as <tt>--prompt</tt>.</td>
</tr>
<tr>
  <td><tt>--inf-ruby-mode</tt></td>
  <td>Sets up irb to run in <tt>inf-ruby-mode</tt>
                          under Emacs. Changes the prompt and
                          suppresses
                          <tt>--readline</tt>.</td>
</tr>
<tr>
  <td><tt>--simple-prompt</tt></td>
  <td>Simple prompt mode.</td>
</tr>
<tr>
  <td><tt>--noprompt</tt></td>
  <td>Do not display a prompt.</td>
</tr>
<tr>
  <td><tt>--tracer</tt></td>
  <td>Display trace for execution of commands.</td>
</tr>
<tr>
  <td><tt>--back-trace-limit n</tt></td>
  <td>Display backtrace information using
                          the top n and last n entries. 
                          The default value is 16.</td>
</tr>
<tr>
  <td><tt>--irb_debug n</tt></td>
  <td>Set internal debug level to n (only for
                            irb development).</td>
</tr>
<tr>
  <td><tt>-v, --version</tt></td>
  <td>Print the version of irb.</td>
</tr>
<bottomrule/></table>
<p/>
</figure>
<p/>
<section>Initialization File</section>
<p/>
irb uses an initialization file in which you can set commonly used
options or execute any required Ruby statements.  When irb is run, it
will try to load an initialization file from one of the following
sources in order: <tt>~/.irbrc</tt>, <tt>.irbrc</tt>, <tt>irb.rc</tt>,
<tt>_irbrc</tt>, and <tt>$irbrc</tt>.
<p/>
Within the initialization file you may run any arbitrary Ruby code.
You can also set any of the configuration values that correspond to
command-line arguments as shown in Table B.2 on page 518.
<figure type="table">
<caption>irb configuration values</caption>
<center>
<table>
<p/>
<toprule/><tr>
  <td><tt>IRB.conf[:IRB_NAME] = "irb"</tt></td>
  <td><tt>IRB.conf[:MATH_MODE] = false</tt></td>
</tr>
<tr>
  <td><tt>IRB.conf[:USE_TRACER] = false</tt></td>
  <td><tt>IRB.conf[:USE_LOADER] = false</tt></td>
</tr>
<tr>
  <td><tt>IRB.conf[:IGNORE_SIGINT] = true</tt></td>
  <td><tt>IRB.conf[:IGNORE_EOF] = false</tt></td>
</tr>
<tr>
  <td><tt>IRB.conf[:INSPECT_MODE] = nil</tt></td>
  <td><tt>IRB.conf[:IRB_RC] = nil</tt></td>
</tr>
<tr>
  <td><tt>IRB.conf[:BACK_TRACE_LIMIT] = 16</tt></td>
  <td><tt>IRB.conf[:USE_LOADER] = false</tt></td>
</tr>
<tr>
  <td><tt>IRB.conf[:USE_READLINE] = nil</tt></td>
  <td><tt>IRB.conf[:USE_TRACER] = false</tt></td>
</tr>
<tr>
  <td><tt>IRB.conf[:IGNORE_SIGINT] = true</tt></td>
  <td><tt>IRB.conf[:IGNORE_EOF] = false</tt></td>
</tr>
<tr>
  <td><tt>IRB.conf[:PROMPT_MODE] = :DEFAULT</tt></td>
  <td><tt>IRB.conf[:PROMPT] = { ...<nbsp/>}</tt></td>
</tr>
<tr>
  <td><tt>IRB.conf[:DEBUG_LEVEL] = 0</tt></td>
  <td><tt>IRB.conf[:VERBOSE] = true</tt></td>
</tr>
<bottomrule/></table>
<p/>
</center>
</figure>
<p/>
As an interesting twist on configuring irb, you can set
<tt>IRB.conf[:IRB_RC]</tt> to a <classname>Proc</classname> object.  This proc will be
invoked whenever the irb context is changed, and will receive that new
context as a parameter.  You can use this facility to change the
configuration dynamically based on the context.
<section>Commands</section>
<p/>
At the irb prompt, you can enter any valid Ruby expression and see the
results.  You can also use any of the following commands to control
the irb session.
<p/>
<dl>
<p/>
  <dt><tt>exit, quit, irb_exit</tt></dt><dd>
    Quits this irb session or subsession.
    If you've used <tt>cb</tt> to change bindings (see below), exits from 
    this binding mode.
<p/>
  </dd><dt><tt>conf, irb_context</tt></dt><dd>
    Displays current configuration. Modifying the configuration is
    achieved by invoking methods of <tt>conf</tt>.
<p/>
  </dd><dt><tt>conf.back_trace_limit n</tt></dt><dd>
    Sets display lines of backtrace as top n and tail n. 
    The default value is 16.
<p/>
  </dd><dt><tt>conf.debug_level = N</tt></dt><dd>
    Sets debug level of irb. 
<p/>
  </dd><dt><tt>conf.ignore_eof = true/false</tt></dt><dd>
    Specifies the behavior of an end of file received on input.
    If true, it will be ignored; otherwise, it will quit irb.
<p/>
  </dd><dt><tt>conf.ignore_sigint= true/false</tt></dt><dd>
    Specifies the behavior of ^C (control-c).  
    If false, ^C will quit irb. If true, ^C
    during input will cancel input and return to the top level;
    during execution, ^C will abort the current operation.
<p/>
  </dd><dt><tt>conf.inf_ruby_mode = true/false</tt></dt><dd>
    If <tt>true</tt>, changes the prompt and disables readline support,
    allowing irb to work with
    <tt>inf-ruby-mode</tt>.    <footnote><tt>inf-ruby-mode</tt> allows Emacs      
      users to interact with
      Ruby while editing programs. See the file <tt>inf_ruby.el</tt> in the
      <tt>misc</tt> directory of the distribution for more details.</footnote>  The
    default value is false.
<p/>
  </dd><dt><tt>conf.inspect_mode = true/false/nil</tt></dt><dd>
    Specifies inspect mode according to the following values:
<p/>
    <table>
<tr>
  <td><tt>true</tt></td>
  <td>Display inspect (default).</td>
</tr>
<tr>
  <td><tt>false</tt></td>
  <td>Display to_s.</td>
</tr>
<tr>
  <td><tt>nil</tt></td>
  <td>Inspect mode in non-math mode, 
            non-inspect mode in math mode.</td>
</tr>
</table>
<p/>
  </dd><dt><tt>conf.irb_level</tt></dt><dd>
    Displays the current binding level (see <tt>cb</tt>).
<p/>
  </dd><dt><tt>conf.math_mode</tt></dt><dd>
    Displays whether or not Ruby is in math mode.
<p/>
  </dd><dt><tt>conf.use_loader = true/false</tt></dt><dd>
    Specifies whether or not irb's own file reader method is used with
    <tt>load</tt>/<tt>require</tt>. 
<p/>
  </dd><dt><tt>conf.prompt_c</tt></dt><dd> 
    The prompt for a continuing statement
    (for example, immediately after an ``if'').
<p/>
  </dd><dt><tt>conf.prompt_i</tt></dt><dd>
    The standard, top-level prompt.
<p/>
  </dd><dt><tt>conf.prompt_s</tt></dt><dd>
    The prompt for a continuing string.
<p/>
  </dd><dt><tt>conf.rc = true/false</tt></dt><dd>
    Specifies whether or not to use the initialization file
    <tt>~/.irbrc</tt>.
<p/>
  </dd><dt><tt>conf.use_prompt = true/false</tt></dt><dd>
    Specifies whether or not to display prompts.
<p/>
  </dd><dt><tt>conf.use_readline = true/false/nil</tt></dt><dd>
    Specifies whether or not to use Readline according to the following
    values:
<p/>
    <table>
<tr>
  <td><tt>true</tt></td>
  <td>Use Readline.</td>
</tr>
<tr>
  <td><tt>false</tt></td>
  <td>Do not use Readline.</td>
</tr>
<tr>
  <td><tt>nil</tt></td>
  <td>Use Readline except for <tt>inf-ruby-mode</tt> (default).</td>
</tr>
</table>
<p/>
  </dd><dt><tt>conf.verbose=true/false</tt></dt><dd>
    Specifies whether or not verbose messages are displayed. 
<p/>
  </dd><dt><tt>cb, irb_change_binding <opt><obj>obj</obj></opt></tt></dt><dd>
    Creates and enters a new binding that has its own scope for
    local variables. If <obj>obj</obj> is given, it will be used as self in 
    the new binding.
<p/>
  </dd><dt><tt>irb <opt>obj</opt></tt></dt><dd>
    Starts an irb subsession. If <obj>obj</obj> is given, it will be used
    as self.
<p/>
  </dd><dt><tt>jobs, irb_jobs</tt></dt><dd>
    Lists irb subsessions.
<p/>
  </dd><dt><tt>fg n, irb_fg n</tt></dt><dd>
    Switches into the specified irb subsession. n may be any of the
    following values:
<p/>
    <table>
<tr>
  <td>irb subsession number</td>
</tr>
<tr>
  <td>thread id</td>
</tr>
<tr>
  <td>irb object</td>
</tr>
<tr>
  <td>self (the <obj>obj</obj> that launched a particular subsession)</td>
</tr>
</table>
<p/>
  </dd><dt><tt>kill n, irb_kill n</tt></dt><dd>
    Kills an irb subsession. n may be any of the values as described 
    for <tt>irb_fg</tt>.
<p/>
</dd></dl>
<subsection>Configuring the Prompt</subsection>
<p/>
You have a lot of flexibility in configuring the prompts that irb
uses.  Sets of prompts are stored in the prompt hash:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[  IRB.conf[:PROMPT]
]]></fullcode>
IRB.conf[:PROMPT]
</alltt>
</codefragment>
<p/>
For example, to establish a new prompt mode called ``MY_PROMPT'', you
might enter the following (either directly at an irb prompt or in the 
<tt>.irbrc</tt> file):
<p/>
<codefragment>
<alltt><fullcode><![CDATA[IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
  :PROMPT_I => "...",             # normal prompt
  :PROMPT_S => "...",             # prompt for continuing strings
  :PROMPT_C => "...",             # prompt for continuing statement
  :RETURN => "    ==>%s\n"        # format to return value
}
]]></fullcode>
IRB.conf[:PROMPT][:MY_PROMPT]<nbsp/>=<nbsp/>{<nbsp/>#<nbsp/>name<nbsp/>of<nbsp/>prompt<nbsp/>mode
<nbsp/><nbsp/>:PROMPT_I<nbsp/>=&gt;<nbsp/>"...",<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>#<nbsp/>normal<nbsp/>prompt
<nbsp/><nbsp/>:PROMPT_S<nbsp/>=&gt;<nbsp/>"...",<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>#<nbsp/>prompt<nbsp/>for<nbsp/>continuing<nbsp/>strings
<nbsp/><nbsp/>:PROMPT_C<nbsp/>=&gt;<nbsp/>"...",<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>#<nbsp/>prompt<nbsp/>for<nbsp/>continuing<nbsp/>statement
<nbsp/><nbsp/>:RETURN<nbsp/>=&gt;<nbsp/>"<nbsp/><nbsp/><nbsp/><nbsp/>==&gt;%s\n"<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>#<nbsp/>format<nbsp/>to<nbsp/>return<nbsp/>value
}
</alltt>
</codefragment>
<p/>
Then, invoke irb with the prompt mode above by
<p/>
<alltt>
<tt>%<nbsp/>irb --prompt my-prompt</tt>
</alltt>
<p/>
Or set the following configuration value:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[  IRB.conf[:PROMPT_MODE] = :MY_PROMPT
]]></fullcode>
IRB.conf[:PROMPT_MODE]<nbsp/>=<nbsp/>:MY_PROMPT
</alltt>
</codefragment>
<p/>
The constants <tt>PROMPT_I</tt>, <tt>PROMPT_S</tt>, and <tt>PROMPT_C</tt>
specify the format for each of the prompt strings.  Within the prompt
format, the following flags are available and will expand to the
given text:
<p/>
<table>
<th>
  <td><b>Flag</b></td>
  <td><b>Description</b></td>
</th>
<tr>
  <td><tt>%N</tt></td>
  <td>Current command.</td>
</tr>
<tr>
  <td><tt>%m</tt></td>
  <td><tt>to_s</tt> of the main object (self).</td>
</tr>
<tr>
  <td><tt>%M</tt></td>
  <td><tt>inspect</tt> of the main object (self).</td>
</tr>
<tr>
  <td><tt>%l</tt></td>
  <td>Delimiter type. In strings that are continued across a line break,
         <tt>%l</tt> will display the type of delimiter used to begin the
         string, so you'll know how to end it.  The delimiter will be
         one of <tt>"</tt>, <tt>'</tt>, <tt>/</tt>, <tt>]</tt>, or <tt>`</tt>.</td>
</tr>
<tr>
  <td><tt>%ni</tt></td>
  <td>Indent level. The optional number n is used as a width 
            specification to printf, as <tt>printf("%nd")</tt>.</td>
</tr>
<tr>
  <td><tt>%nn</tt></td>
  <td>Current line number (n used as with the indent level).</td>
</tr>
<tr>
  <td><tt>%%</tt></td>
  <td>A literal percent sign.</td>
</tr>
<bottomrule/></table>
<p/>
For instance, the default prompt mode is defined as follows:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[IRB.conf[:PROMPT_MODE][:DEFAULT] = {
      :PROMPT_I => "%N(%m):%03n:%i> ",
      :PROMPT_S => "%N(%m):%03n:%i%l ",
      :PROMPT_C => "%N(%m):%03n:%i* ",
      :RETURN => "%s\n"
} 
]]></fullcode>
IRB.conf[:PROMPT_MODE][:DEFAULT]<nbsp/>=<nbsp/>{
<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>:PROMPT_I<nbsp/>=&gt;<nbsp/>"%N(%m):%03n:%i&gt;<nbsp/>",
<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>:PROMPT_S<nbsp/>=&gt;<nbsp/>"%N(%m):%03n:%i%l<nbsp/>",
<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>:PROMPT_C<nbsp/>=&gt;<nbsp/>"%N(%m):%03n:%i*<nbsp/>",
<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>:RETURN<nbsp/>=&gt;<nbsp/>"%s\n"
}
</alltt>
</codefragment>
<section>Restrictions</section>
<p/>
Because of the way irb works, there is a minor incompatibility between
it and the standard Ruby interpreter.  The problem lies in the
determination of local variables.
<p/>
Normally, Ruby looks for an assignment statement to determine if
something is a variable---if a name hasn't been assigned to, then Ruby
assumes that name is a method call.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[  eval "a = 0" 
  a
]]></fullcode>
eval<nbsp/>"a<nbsp/>=<nbsp/>0"
a
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
prog.rb:2: undefined local variable or method `a'<br/>for #&lt;Object:0x401c0ce0&gt; (NameError)
</alltt>
</codefragment>
<p/>
In this case, the assignment is there, but it's within a string, so
Ruby doesn't take it into account.
<p/>
irb, on the other hand, executes statements as they are entered. 
<p/>
<alltt>
  irb(main):001:0&gt; eval "a = 0"
  0
  irb(main):002:0&gt; a
  0
</alltt>
<p/>
In irb, the assignment was executed before the second line was
encountered, so ``a'' is correctly identified as a local variable.
<p/>
If you need to match the Ruby behavior more closely, you can place
these statements within a <tt>begin</tt>/<tt>end</tt> pair.
<p/>
<alltt>
  irb(main):001:0&gt; begin
  irb(main):002:1*   eval "a = 0"
  irb(main):003:1&gt;   a
  irb(main):004:1&gt; end
  NameError: undefined local variable or method `a'
  (irb):3:in `irb_binding'
</alltt>
<section>rtags, xmp, and the Frame Class</section>
<p/>
The base version of irb is installed along with Ruby itself.  But
there is an extended version of irb in the archives containing a
few extra goodies that need mentioning.
<subsubsection>rtags</subsubsection>
<p/>
<tt>rtags</tt> is a command used to create a <tt>TAGS</tt> file for use with
either the emacs or vi editor.  
<p/>
<syntax>
rtags <opt><nt>-vi</nt></opt> <opt><nt>files</nt></opt>...</syntax>
<p/>
By default, rtags makes a <tt>TAGS</tt> file suitable for emacs (see
etags.el). The <tt>-vi</tt> option makes a TAGS file for use with vi.
<p/>
rtags needs to be installed in the same manner as irb (that is, you
need to install irb in the library path and make a link from
<tt>irb/rtags.rb</tt> to <tt>bin/rtags</tt>).
<subsubsection>xmp</subsubsection>
<p/>
irb's xmp is an ``example printer''---that is, a pretty-printer that
shows the value of each expression as it is run (much like the script
we wrote to format the examples in this book). There is also another
stand-alone xmp in the archives.
<p/>
xmp can be used as follows:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[require "irb/xmp"

xmp <<END
artist = "Doc Severinsen"
artist
END
]]></fullcode>
require<nbsp/>"irb/xmp"
<p/>
xmp<nbsp/>&lt;&lt;END
artist<nbsp/>=<nbsp/>"Doc<nbsp/>Severinsen"
artist
END
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
[pwd:/tc/work/ruby/ProgrammingRuby/latex]
artist<nbsp/>=<nbsp/>"Doc<nbsp/>Severinsen"
<nbsp/><nbsp/><nbsp/><nbsp/>==&gt;"Doc<nbsp/>Severinsen"
artist
<nbsp/><nbsp/><nbsp/><nbsp/>==&gt;"Doc<nbsp/>Severinsen"
</alltt>
</codefragment>
<p/>
Or, it can be used as an object instance.  Used in this fashion, the
object maintains context between invocations:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[require "irb/xmp"

x = XMP.new
x.puts <<END
artist = "Louis Prima"
END

x.puts <<END
artist
END
]]></fullcode>
require<nbsp/>"irb/xmp"
<p/>
x<nbsp/>=<nbsp/>XMP.new
x.puts<nbsp/>&lt;&lt;END
artist<nbsp/>=<nbsp/>"Louis<nbsp/>Prima"
END
<p/>
x.puts<nbsp/>&lt;&lt;END
artist
END
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
[pwd:/tc/work/ruby/ProgrammingRuby/latex]
artist<nbsp/>=<nbsp/>"Louis<nbsp/>Prima"
<nbsp/><nbsp/><nbsp/><nbsp/>==&gt;"Louis<nbsp/>Prima"
artist
<nbsp/><nbsp/><nbsp/><nbsp/>==&gt;"Louis<nbsp/>Prima"
</alltt>
</codefragment>
<p/>
You can explicitly provide a binding with either form; otherwise, xmp
uses the caller's environment.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[  xmp code_string, abinding
  XMP.new(abinding)
]]></fullcode>
xmp<nbsp/>code_string,<nbsp/>abinding
XMP.new(abinding)
</alltt>
</codefragment>
<p/>
Note that xmp does not work with multithreading.
<subsubsection>The Frame Class</subsubsection>
<p/>
The <classname>IRB::Frame</classname> class represents the interpreter's stack and allows
easy access to the <classname>Binding</classname> environment in effect at different
stack levels. 
<p/>
<table>
<p/>
  <toprule/><tr>
  <td><tt>IRB::Frame.top(<em>n = 0</em>)</tt></td>
  <td>Returns a <classname>Binding</classname>
  for the nth context from the top. The 0th context is
  topmost,
  most recent frame.</td>
</tr>
<tr>
  <td><tt>IRB::Frame.bottom(<em>n = 0</em>)</tt></td>
  <td>Returns a <classname>Binding</classname> for the
  nth context from the bottom. The 0th context is the
  bottommost, initial frame.</td>
</tr>
<tr>
  <td><tt>IRB::Frame.sender</tt></td>
  <td>Returns the object (the sender)
  that invoked the current method.</td>
</tr>
<bottomrule/></table>
<p/>
You can use this facility, for instance, to examine local variables
from the method that called the current method:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[  require 'irb/frame'

  def outie
    b = IRB::Frame.top(1)
    eval "p my_local", b
  end

  def innie
    my_local = 102.7
    outie
  end

  innie
]]></fullcode>
require<nbsp/>'irb/frame'
<p/>
def<nbsp/>outie
<nbsp/><nbsp/>b<nbsp/>=<nbsp/>IRB::Frame.top(1)
<nbsp/><nbsp/>eval<nbsp/>"p<nbsp/>my_local",<nbsp/>b
end
<p/>
def<nbsp/>innie
<nbsp/><nbsp/>my_local<nbsp/>=<nbsp/>102.7
<nbsp/><nbsp/>outie
end
<p/>
innie
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
102.7
</alltt>
</codefragment>
<p/>
Note that this doesn't work with multithreaded programs.
</chapter>
</ppdoc>
