<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Merlin/Main/Languages/Ruby/Samples/Tutorial/Tutorials/hosting_tutorial.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -72,8 +72,7 @@
 # the Islamic Calendar, or the French Revolutionary Calendar
 # are not supported by the Date class; nor are calendars that
 # are based on an Era different from the Common Era, such as
-# the Japanese Imperial Calendar or the Republic of China
-# Calendar.
+# the Japanese Imperial Calendar.
 #
 # === Calendar Reform
 #</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/1.8/date.rb</filename>
    </modified>
    <modified>
      <diff>@@ -174,7 +174,7 @@ module REXML
     #   the absolute *value* of the document -- that is, it leaves the value
     #   and number of Text nodes in the document unchanged.
     # ie_hack::
-    #   Internet Explorer is the worst piece of crap to have ever been
+    #   Internet Explorer is the worst piece of #### to have ever been
     #   written, with the possible exception of Windows itself.  Since IE is
     #   unable to parse proper XML, we have to provide a hack to generate XML
     #   that IE's limited abilities can handle.  This hack inserts a space </diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/1.8/rexml/document.rb</filename>
    </modified>
    <modified>
      <diff>@@ -662,7 +662,7 @@ module REXML
     #   pretty-printed in such a way that the added whitespace does not affect
     #   the parse tree of the document
     # ie_hack::
-    #   Internet Explorer is the worst piece of crap to have ever been
+    #   Internet Explorer is the worst piece of #### to have ever been
     #   written, with the possible exception of Windows itself.  Since IE is
     #   unable to parse proper XML, we have to provide a hack to generate XML
     #   that IE's limited abilities can handle.  This hack inserts a space </diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/1.8/rexml/element.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ require 'rexml/source'
 require 'rexml/xmltokens'
 
 module REXML
-	# God, I hate DTDs.  I really do.  Why this idiot standard still
+	# God, I hate DTDs.  I really do.  Why this ##### standard still
 	# plagues us is beyond me.
 	class Entity &lt; Child
 		include XMLTokens</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/1.8/rexml/entity.rb</filename>
    </modified>
    <modified>
      <diff>@@ -100,7 +100,7 @@ require 'rubygems/gem_openssl'
 #   Unfortunately, MediumSecurity still isn't totally secure -- a
 #   malicious user can still unpack the gem, strip the signatures, and
 #   distribute the gem unsigned.
-# * HighSecurity - Here's the bugger that got us into this mess.
+# * HighSecurity - Here's the ###### that got us into this mess.
 #   The HighSecurity policy is identical to the MediumSecurity policy,
 #   except that it does not allow unsigned gems.  A malicious user
 #   doesn't have a whole lot of options here; he can't modify the</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/site_ruby/1.8/rubygems/security.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@
   &lt;microsoft.scripting&gt;
     &lt;languages&gt;
       &lt;language names=&quot;IronPython;Python;py&quot; extensions=&quot;.py&quot; displayName=&quot;IronPython 2.6 Alpha&quot; type=&quot;IronPython.Runtime.PythonContext, IronPython, Version=2.6.0.10, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; /&gt;
-      &lt;language names=&quot;IronRuby;Ruby;rb&quot; extensions=&quot;.rb&quot; displayName=&quot;IronRuby&quot; type=&quot;IronRuby.Runtime.RubyContext, IronRuby, Version=0.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; /&gt;
+      &lt;language names=&quot;IronRuby;Ruby;rb&quot; extensions=&quot;.rb&quot; displayName=&quot;IronRuby&quot; type=&quot;IronRuby.Runtime.RubyContext, IronRuby, Version=0.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; /&gt;
     &lt;/languages&gt;
 
     &lt;options&gt;</diff>
      <filename>Merlin/Main/Config/Signed/App.config</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@
   &lt;microsoft.scripting&gt;
     &lt;languages&gt;
       &lt;language names=&quot;IronPython;Python;py&quot; extensions=&quot;.py&quot; displayName=&quot;IronPython 2.6 Alpha&quot; type=&quot;IronPython.Runtime.PythonContext, IronPython, Version=2.6.0.10, Culture=neutral, PublicKeyToken=null&quot; /&gt;
-      &lt;language names=&quot;IronRuby;Ruby;rb&quot; extensions=&quot;.rb&quot; displayName=&quot;IronRuby&quot; type=&quot;IronRuby.Runtime.RubyContext, IronRuby, Version=0.5.0.0, Culture=neutral, PublicKeyToken=null&quot; /&gt;
+      &lt;language names=&quot;IronRuby;Ruby;rb&quot; extensions=&quot;.rb&quot; displayName=&quot;IronRuby&quot; type=&quot;IronRuby.Runtime.RubyContext, IronRuby, Version=0.6.0.0, Culture=neutral, PublicKeyToken=null&quot; /&gt;
     &lt;/languages&gt;
 
     &lt;options&gt;</diff>
      <filename>Merlin/Main/Config/Unsigned/App.config</filename>
    </modified>
    <modified>
      <diff>@@ -236,11 +236,13 @@ namespace Microsoft.Scripting.Silverlight {
                 var multiLine = _code.Split('\n').Length &gt; 1;
                 
                 object result = null;
+                _outputBuffer.UserOutput = true;
                 if (_code != string.Empty &amp;&amp; !multiLine) {
                     result = DoSingleLine(forceExecute);
                 } else {
                     result = DoMultiLine(forceExecute);
                 }
+                _outputBuffer.UserOutput = false;
 
                 ShowLineAndResult(line, result);
             }
@@ -361,7 +363,7 @@ namespace Microsoft.Scripting.Silverlight {
         }
 
         internal string SubPromptHtml() {
-            return &quot;  | &quot;;
+            return &quot;... &quot;;
         }
         #endregion
 
@@ -376,7 +378,6 @@ namespace Microsoft.Scripting.Silverlight {
 
         internal void ShowPromptInResultDiv() {
             _outputBuffer.ElementClass = _sdlrPrompt;
-            _outputBuffer.ElementName = &quot;span&quot;;
             _outputBuffer.Write(_multiLinePrompt ? SubPromptHtml() : PromptHtml());
             _outputBuffer.Reset();
             if (_multiLine) {
@@ -422,6 +423,7 @@ namespace Microsoft.Scripting.Silverlight {
     public class ReplOutputBuffer : ConsoleWriter {
         public string ElementClass;
         public string ElementName;
+        public bool UserOutput;
         private HtmlElement _results;
         private string _outputClass;
         private string _queue;
@@ -429,16 +431,17 @@ namespace Microsoft.Scripting.Silverlight {
         public ReplOutputBuffer(HtmlElement results, string outputClass) {
             _results = results;
             _outputClass = outputClass;
+            _queue = &quot;&quot;;
+            Reset();
         }
 
         public string Queue { get { return _queue; } }
 
         public override void Write(string str) {
-            if (ElementName == null) {
+            if (UserOutput) {
                 _queue += str;
             } else {
-                str = str == String.Empty ? &quot; &quot; : str;
-                _results.AppendChild(PutTextInNewElement(str, ElementName, ElementClass));
+                AppendToResults(str);
             }
         }
 
@@ -446,19 +449,33 @@ namespace Microsoft.Scripting.Silverlight {
             Write(str);
         }
 
+        public void flush() {
+            Flush();
+        }
+
         public void Reset() {
             ElementClass = null;
-            ElementName = null;
+            ElementName = &quot;span&quot;;
+            UserOutput = false;
         }
 
         public override void Flush() {
-            if (_queue != null) {
-                _results.AppendChild(PutTextInNewElement(_queue, &quot;div&quot;, _outputClass));
-                _queue = null;
+            if (_queue != string.Empty) {
+                AppendToResults(_queue, _outputClass);
+                _queue = string.Empty;
             }
         }
 
         #region HTML Helpers
+        private void AppendToResults(string str) {
+            AppendToResults(str, null);
+        }
+
+        private void AppendToResults(string str, string outputClass) {
+            str = str == String.Empty ? &quot; &quot; : str;
+            _results.AppendChild(PutTextInNewElement(str, ElementName, outputClass ?? ElementClass));
+        }
+
         // TODO any library I can use to do this?
         private static string EscapeHtml(string text) {
             return text.Replace(&quot;\t&quot;, &quot;  &quot;).
@@ -471,7 +488,7 @@ namespace Microsoft.Scripting.Silverlight {
         }
 
         private HtmlElement PutTextInNewElement(string str, string tagName, string className) {
-            var element = HtmlPage.Document.CreateElement(tagName == null ? &quot;div&quot; : tagName);
+            var element = HtmlPage.Document.CreateElement(tagName == null ? &quot;span&quot; : tagName);
             if (className != null) {
                 element.CssClass = className;
             }</diff>
      <filename>Merlin/Main/Hosts/SilverLight/Microsoft.Scripting.SilverLight/Repl.cs</filename>
    </modified>
    <modified>
      <diff>@@ -47,8 +47,8 @@ namespace IronRuby.Runtime {
         public static readonly string/*!*/ MriReleaseDate = &quot;2008-05-28&quot;;
 
         // IronRuby:
-        public const string/*!*/ IronRubyVersionString = &quot;0.5.0.0&quot;;
-        public static readonly Version IronRubyVersion = new Version(0, 5, 0, 0);
+        public const string/*!*/ IronRubyVersionString = &quot;0.6.0.0&quot;;
+        public static readonly Version IronRubyVersion = new Version(0, 6, 0, 0);
         internal const string/*!*/ IronRubyDisplayName = &quot;IronRuby&quot;;
         internal const string/*!*/ IronRubyNames = &quot;IronRuby;Ruby;rb&quot;;
         internal const string/*!*/ IronRubyFileExtensions = &quot;.rb&quot;;</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs</filename>
    </modified>
    <modified>
      <diff>@@ -124,15 +124,15 @@ tutorial &quot;IronRuby tutorial&quot; do
 
             task(:body =&gt; &quot;Now let's do some printing. This is done with the puts function.&quot;,
                  :code =&gt; &quot;puts 'Hello world'&quot;
-                 ) { |i| i.output =~ /Hello/i }
+                 ) { |iar| iar.output =~ /Hello/i }
 
             task(:body =&gt; &quot;Let's use a local variable.&quot;,
                  :code =&gt; &quot;x = 1&quot;
-                 ) { |i| i.bind.x == 1 }
+                 ) { |iar| iar.bind.x == 1 }
 
             task(:body =&gt; &quot;And then print the local variable.&quot;,
                  :code =&gt; &quot;puts x&quot;
-                 ) { |i| i.output.chomp == &quot;1&quot; }
+                 ) { |iar| iar.output.chomp == &quot;1&quot; }
         end
         
         chapter &quot;Multi-line statements&quot; do
@@ -189,7 +189,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                      as you saw above. Some need to be explicitly loaded. This is done with the the +require+
                      function. Let's load the +thread+ module.
                  },
-                 :setup =&gt; Proc.new { $LOADED_FEATURES.delete &quot;thread.rb&quot; },
+                 :setup =&gt; lambda { $LOADED_FEATURES.delete &quot;thread.rb&quot; },
                  :code =&gt; &quot;require 'thread'&quot;
                  ) { $LOADED_FEATURES.include? 'thread.rb' }
                  
@@ -218,7 +218,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                        require './primes.rb'
                  },
                  :source_files =&gt; IronRubyTutorial.primes_path,
-                 :setup =&gt; Proc.new { $LOADED_FEATURES.delete &quot;primes.rb&quot; },
+                 :setup =&gt; lambda { $LOADED_FEATURES.delete &quot;primes.rb&quot; },
                  :code =&gt; &quot;require 'primes.rb'&quot;
                  ) { $LOADED_FEATURES.include? 'primes.rb' }
 
@@ -295,7 +295,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     &quot;h[:a] = 'IronRuby'&quot;, 
                     &quot;h[:b] = 'Tutorial'&quot;]
-                ) { |i| i.bind.h.count == 2 }
+                ) { |iar| iar.bind.h.count == 2 }
 
             task :body =&gt; %{
                     IronRuby supports the C# - style syntax for accessing the hash table elements. The same 
@@ -309,7 +309,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                     each entry.
                 },
                 :code =&gt; 'h.each { |e| puts &quot;#{e.Key}=&gt;#{e.Value}&quot; }'
-                ) { |i| /a=&gt;IronRuby/ =~ i.output }
+                ) { |iar| /a=&gt;IronRuby/ =~ iar.output }
 
             task(:body =&gt; %{
                     You can initialize the collection classes by passing in the Ruby built-in list as
@@ -318,7 +318,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     'l = ArrayList.new([1,2,3])', 
                     'l.each { |i| puts i }']
-                ) { |i| /1\n2\n3/ =~ i.output }
+                ) { |iar| /1\n2\n3/ =~ iar.output }
         end
 
         chapter &quot;Generics&quot; do
@@ -336,7 +336,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                    Create an instance of a generic dictionary mapping Strings to Fixnums
                 },
                 :code =&gt; 'd = Dictionary[String, Fixnum].new'
-                ) { |i| i.bind.d.class == Dictionary[String, Fixnum] }
+                ) { |iar| iar.bind.d.class == Dictionary[String, Fixnum] }
 
             task(:body =&gt; %{
                     Add string values into the list. Since we created a list of string, adding strings is possible.
@@ -344,19 +344,19 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     &quot;d['Hello'] = 1&quot;, 
                     &quot;d['Hi'] = 2&quot;]
-                ) { |i| i.bind.d.count == 2 }
+                ) { |iar| iar.bind.d.count == 2 }
 
             task(:body =&gt; %{
                     Try adding objects of types other than string. It will fail with a TypeError
                 },
                 :code =&gt; 'd[3] = 3'
-                ) { |i| i.error.kind_of? TypeError }
+                ) { |iar| iar.error.kind_of? TypeError }
 
             task(:body =&gt; %{
                     Enumerate the generic collection
                 },
                 :code =&gt; 'd.each { |kvp| puts kvp }'
-                ) { |i| /Hello/ =~ i.output }
+                ) { |iar| /Hello/ =~ iar.output }
         end
     end
 
@@ -390,7 +390,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     'd = XmlDocument.new', 
                     &quot;d.load '#{IronRubyTutorial.load_xml_relative_path}'&quot;]
-                ) { |i| i.bind.d.get_elements_by_tag_name(&quot;Puzzle&quot;).count == 1 }
+                ) { |iar| iar.bind.d.get_elements_by_tag_name(&quot;Puzzle&quot;).count == 1 }
 
             task(:body =&gt; %{
                     We can now query the document. Use the statements below to get output like:
@@ -403,7 +403,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     &quot;n = d.select_nodes '//Puzzle/SavedGames/Game/@caption'&quot;, 
                     'n.each { |e| puts e.value }']
-                ) { |i| /Seattle/ =~ i.output }
+                ) { |iar| /Seattle/ =~ iar.output }
         end
 
         chapter &quot;Loading .NET libraries from a given path&quot; do
@@ -422,7 +422,7 @@ tutorial &quot;IronRuby tutorial&quot; do
         introduction %{
             The large part of the beauty of IronRuby lies within the dynamic-style development - modifying
             the live application by adding functioning elements to it. With Windows applications, this often 
-            requires delegates and event handling (i.e., adding a button to an existing form and adding 
+            requires delegates and event handling (iar.e., adding a button to an existing form and adding 
             functionality to the button to handle the user pressing the button).
 
             This tutorial will focus on creating delegates, handling events in IronPython, and creating
@@ -438,7 +438,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     'include System::IO', 
                     'w = FileSystemWatcher.new']
-                ) { |i| i.bind.w.class == System::IO::FileSystemWatcher }
+                ) { |iar| iar.bind.w.class == System::IO::FileSystemWatcher }
 
             task(:body =&gt; %{
                     Inspect the methods available on the instance, and then set the +path+ property to watch
@@ -447,14 +447,14 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     'w.class.instance_methods false', 
                     &quot;w.path = '.'&quot;]
-                ) { |i| i.bind.w.path == '.' }
+                ) { |iar| iar.bind.w.path == '.' }
 
             task(:body =&gt; %{
                     Register a block as an event handler for the +changed+, +created+, and +deleted+ events. 
                     Because we don't know yet what arguments the block will have, let's accept any number of 
                     arguments (the &lt;tt&gt;*a&lt;/tt&gt; notation).
                 },
-                :setup =&gt; Proc.new { |bind| IronRubyTutorial.snoop_add_handler &quot;deleted&quot;, bind.w },
+                :setup =&gt; lambda { |bind| IronRubyTutorial.snoop_add_handler &quot;deleted&quot;, bind.w },
                 :code =&gt; [
                     'w.changed { |*a| puts a.inspect }', 
                     'w.created { |*a| puts a.inspect }', 
@@ -465,7 +465,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                     Enable the watcher to raise events.
                 },
                 :code =&gt; 'w.enable_raising_events = true'
-                ) { |i| i.bind.w.enable_raising_events }
+                ) { |iar| iar.bind.w.enable_raising_events }
 
             task(:body =&gt; %{
                     Now open the Tutorial folder and create a file. An 
@@ -484,11 +484,21 @@ tutorial &quot;IronRuby tutorial&quot; do
                     Finally disable the watcher.
                 },
                 :code =&gt; 'w.enable_raising_events = false'
-                ) { |i| not i.bind.w.enable_raising_events }
+                ) { |iar| not iar.bind.w.enable_raising_events }
         end
 
         chapter &quot;Improving the event handler&quot; do
 
+            task(:run_unless =&gt; lambda { |bind| bind.w.kind_of? FileSystemWatcher },
+                 :body =&gt; %{
+                    This chapter uses the variable +w+. Execute the following code or run the previous
+                    chapter to set +w+.
+                },
+                :code =&gt; [
+                    'include System::IO',
+                    'w = FileSystemWatcher.new']
+                ) { |iar| iar.bind.w.kind_of? System::IO::FileSystemWatcher }
+
             task :body =&gt; %{
                     In the previous task, we can see that the types of the parameters passed to all three 
                     events were the same:
@@ -499,12 +509,6 @@ tutorial &quot;IronRuby tutorial&quot; do
                     Use +instance_methods+ to explore the event arguments class to find what information 
                     the event contains.
                 },
-                :setup =&gt; Proc.new { |bind|
-                    include System::IO
-                    eval %{
-                        w = FileSystemWatcher.new unless defined? w and w.class == FileSystemWatcher
-                    }, bind
-                },
                 :code =&gt; 'FileSystemEventArgs.instance_methods(false)'
 
             task(:body =&gt; %{
@@ -512,7 +516,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                     handler that will print +change_type+ and +full_path+ properties of the event argument 
                     object.
                 },
-                :setup =&gt; Proc.new { |bind| IronRubyTutorial.snoop_add_handler &quot;deleted&quot;, bind.w },
+                :setup =&gt; lambda { |bind| IronRubyTutorial.snoop_add_handler &quot;deleted&quot;, bind.w },
                 :code =&gt; [
                     'w.changed { |w1,a| puts a.change_type, a.full_path }',
                     'w.created { |w1,a| puts a.change_type, a.full_path }',
@@ -523,13 +527,13 @@ tutorial &quot;IronRuby tutorial&quot; do
                     Make sure the raising of the events is enabled:
                 },
                 :code =&gt; 'w.enable_raising_events = true'
-                ) { |i| i.bind.w.enable_raising_events }
+                ) { |iar| iar.bind.w.enable_raising_events }
 
             task(:body =&gt; %{
                     Finally disable the watcher.
                 },
                 :code =&gt; 'w.enable_raising_events = false'
-                ) { |i| not i.bind.w.enable_raising_events }
+                ) { |iar| not iar.bind.w.enable_raising_events }
         end
 
     end
@@ -574,7 +578,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                     Create an instance of the Form class and display it.
                 },
                 :code =&gt; ['f = Form.new', 'f.show']
-                ) { |i| i.bind.f.visible }
+                ) { |iar| iar.bind.f.visible }
 
             task(:body =&gt; %{
                     You may need to alt-tab or look for the running application since it may not have popped
@@ -582,28 +586,31 @@ tutorial &quot;IronRuby tutorial&quot; do
                     
                     Now set the form Text property.
                 },
-                :setup =&gt; Proc.new {
+                :setup =&gt; lambda {
                     # TODO - Position the form so that it is not hidden behind the current window
                 },
                 :code =&gt; &quot;f.text = 'Hello'&quot;
-                ) { |i| /hello/i =~ i.bind.f.text }
+                ) { |iar| /hello/i =~ iar.bind.f.text }
         end
         
         chapter &quot;Adding event handlers to the Form&quot; do
+            task(:run_unless =&gt; lambda { |bind| bind.f.visible },
+                 :body =&gt; %{
+                    This chapter uses the variable +f+. Execute the following code, or run the previous
+                    chapter to initialize the +f+.
+                },
+                :code =&gt; [
+                    &quot;load_assembly 'System.Windows.Forms'&quot;,
+                    'include System::Windows::Forms',
+                    'f = Form.new',
+                    'f.show']
+                ) { |iar| iar.bind.f.visible }
+
             task(:body =&gt; %{
                     To bring the application alive, let's focus on the +click+ event of the form. Create an 
                     event handler for the +click+ event and click on the form to receive the event. 
                 },
-                :setup =&gt; Proc.new { |bind|
-                    load_assembly 'System.Windows.Forms'
-                    include System::Windows::Forms
-                    eval %{
-                        f = Form.new unless defined? f and f.class == Form
-                        f.show
-                    }, bind
-
-                    IronRubyTutorial.snoop_add_handler &quot;click&quot;, bind.f
-                },
+                :setup =&gt; lambda { |bind| IronRubyTutorial.snoop_add_handler &quot;click&quot;, bind.f },
                 :code =&gt; 'f.click { |*args| puts args }'
                 ) { IronRubyTutorial.click_flag }
 
@@ -629,18 +636,18 @@ tutorial &quot;IronRuby tutorial&quot; do
                         l.location = a.location
                         f.controls.add l
                     end}.strip_margin
-                ) do |i|
+                ) do |iar|
                     f = Tutorial.stub
                     a = Tutorial.stub
                     # &quot;l.location = a.location&quot; is expected to fail because &quot;a.location&quot; currently just returns a Stub
-                    i.bind.on_click(f, a) rescue TypeError
+                    iar.bind.on_click(f, a) rescue TypeError
                     a.called? :location
                 end
 
             task(:body =&gt; %{
                     Now add the method as a +click+ handler
                 },
-                :setup =&gt; Proc.new { |bind| IronRubyTutorial.snoop_add_handler &quot;click&quot;, bind.f },
+                :setup =&gt; lambda { |bind| IronRubyTutorial.snoop_add_handler &quot;click&quot;, bind.f },
                 :code =&gt; 'f.click { |f, a| on_click(f, a) }'
                 ) { IronRubyTutorial.click_flag }
 
@@ -648,7 +655,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                     Now clicking on the form with the mouse will add 'Hello' labels. We can also access the 
                     controls we just added via mouse clicks and change them
                 },
-                :code =&gt; &quot;f.controls.each { |i| i.Text = 'Hi' }&quot;
+                :code =&gt; &quot;f.controls.each { |iar| iar.Text = 'Hi' }&quot;
 
             task(:body =&gt; %{
                     After a few moments of clicking, the form will get quite crowded, so we can clear it out.
@@ -657,7 +664,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     'f.controls.clear', 
                     'f.close']
-                ) { |i| not i.bind.f.visible }
+                ) { |iar| not iar.bind.f.visible }
         end
 
     end
@@ -680,7 +687,10 @@ tutorial &quot;IronRuby tutorial&quot; do
                 },
                 :source_files =&gt; IronRubyTutorial.wpf_path,
                 :code =&gt; &quot;require 'wpf.rb'&quot;
-                ) { |i| [false, true].include? i.result }
+                ) do |iar| 
+                  # TODO - Use stubbing to ensure that require was called with wpf.rb as an argument
+                  not iar.error and iar.input =~ /require.*wpf/ and $LOADED_FEATURES.include? 'wpf.rb'
+                end
 
             task(:body =&gt; %{
                     To make all the WPF class names directly available, you could do:
@@ -697,7 +707,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     'w = Wpf::Window.new', 
                     'w.show']
-                ) { |i| i.bind.w.visibility == System::Windows::Visibility.visible }
+                ) { |iar| iar.bind.w.visibility == System::Windows::Visibility.visible }
 
             task(:body =&gt; %{
                     You may need to alt-tab or look for the running application since it may not have popped 
@@ -709,7 +719,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     'w.size_to_content = Wpf::SizeToContent.width_and_height', 
                     &quot;w.title = 'Hello'&quot;]
-                ) { |i| String.new(i.bind.w.title) =~ /Hello/i } # TODO - String.new should not be needed here
+                ) { |iar| String.new(iar.bind.w.title) =~ /Hello/i } # TODO - String.new should not be needed here
 
             task(:body =&gt; %{
                     Let's add the content now
@@ -718,7 +728,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                     'w.content = Wpf::TextBlock.new',
                     'w.content.text = &quot;Hello IronRuby!&quot;',
                     'w.content.font_size = 50']
-                ) { |i| i.bind.w.content.font_size == 50 }
+                ) { |iar| iar.bind.w.content.font_size == 50 }
 
             task(:body =&gt; %{
                     You can close the window like this&quot;
@@ -729,33 +739,37 @@ tutorial &quot;IronRuby tutorial&quot; do
                     next chapter.
                 },
                 :code =&gt; 'w.content = nil'
-                ) { |i| not i.bind.w.content }
+                ) { |iar| not iar.bind.w.content }
         end
 
         chapter &quot;WPF calculator&quot; do
+            task(:run_unless =&gt; lambda { |bind| bind.w.visibility == System::Windows::Visibility.visible },
+                 :body =&gt; %{
+                    This chapter uses the variable +w+. Execute the following code, or run the previous chapter
+                    to initialize +w+.
+                },
+                :code =&gt; [
+                    &quot;require 'wpf.rb'&quot;,
+                    'w = Wpf::Window.new',
+                    'w.size_to_content = Wpf::SizeToContent.width_and_height',
+                    'w.content = nil',
+                    'w.show']
+                ) { |iar| iar.bind.w.visibility == System::Windows::Visibility.visible }
+
             task(:body =&gt; %{
                     Windows Presentation Foundation uses the XAML format to describe the graphical layout 
                     and basic behaviors of UI. Load the &quot;calc.xaml&quot; file and display the resulting content.
                 },
-                :setup =&gt; Proc.new { |bind|
-                    require 'wpf.rb'
-                    eval %{
-                        w = Wpf::Window.new unless defined? w and w.class == Wpf::Window
-                        w.size_to_content = Wpf::SizeToContent.width_and_height
-                        w.content = nil
-                        w.show
-                    }, bind
-                },
                 :source_files =&gt; IronRubyTutorial.calc_xaml_path,
                 :code =&gt; &quot;w.content = Wpf.load_xaml_file '#{IronRubyTutorial.calc_xaml_relative_path}'&quot;
-                ) { |i| i.bind.w.content }
+                ) { |iar| iar.bind.w.content }
 
             task(:body =&gt; %{
                     Let's walk the calculator's object model using the +walk+ method defined in the &quot;wpf.rb&quot; 
                     file.
                 },
                 :code =&gt; 'Wpf.walk(w) { |c| puts c }'
-                ) { |i| i.output =~ /Button: \+/ }
+                ) { |iar| iar.output =~ /Button: \+/ }
 
             task :body =&gt; %{
                     Let's filter the results to button only
@@ -769,7 +783,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                 :code =&gt; [
                     'buttons.each { |b| b.font_size *= 2 }',
                     'buttons.each { |b| b.foreground = Wpf::SolidColorBrush.new(Wpf::Colors.blue) }']
-                ) { |i| i.bind.buttons.first.foreground.to_s == '#FF0000FF' }
+                ) { |iar| iar.bind.buttons.first.foreground.to_s == '#FF0000FF' }
 
             task :body =&gt; %{
                     If you use &quot;wpf.rb&quot;, you can also access the controls by the name specified in the XAML
@@ -781,7 +795,7 @@ tutorial &quot;IronRuby tutorial&quot; do
             task(:body =&gt; %{
                     Let's define an event handler for the buttons.
                 },
-                :setup =&gt; Proc.new { |bind| eval &quot;on_click = '(undefined)'&quot;, bind },
+                :setup =&gt; lambda { |bind| eval &quot;undef on_click; on_click = '(undefined)'&quot;, bind },
                 :code =&gt; %{
                     def on_click(c, text)
                         if text == 'C' then 
@@ -792,14 +806,14 @@ tutorial &quot;IronRuby tutorial&quot; do
                             c.Result.text = c.Result.text + text
                         end
                     end}.strip_margin
-                ) { |i| i.bind.on_click(Tutorial.stub, '=') == '' }
+                ) { |iar| iar.bind.on_click(Tutorial.stub, '=') == '' }
 
             task(:body =&gt; %{
                     Let's hook up the event handler
                 },
-                :setup =&gt; Proc.new { |bind| IronRubyTutorial.snoop_add_handler &quot;click&quot;, bind.buttons.first },
+                :setup =&gt; lambda { |bind| IronRubyTutorial.snoop_add_handler &quot;click&quot;, bind.buttons.first },
                 :code =&gt; 'buttons.each { |b| b.click { on_click w.content, b.content } }'
-                ) { |i| IronRubyTutorial.click_flag }
+                ) { |iar| IronRubyTutorial.click_flag }
 
             task(:body =&gt; %{
                     Now you should be able to use the calculator!
@@ -807,7 +821,7 @@ tutorial &quot;IronRuby tutorial&quot; do
                     When you are done, close the calculator window.
                 },
                 :code =&gt; 'w.close'
-                ) { |i| not i.bind.w.is_visible }
+                ) { |iar| not iar.bind.w.is_visible }
         end
     end
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Samples/Tutorial/Tutorials/ironruby_tutorial.rb</filename>
    </modified>
    <modified>
      <diff>@@ -33,6 +33,7 @@ class ConsoleTutorial
         prompt = &quot;&gt; &quot;
         chapter.tasks.each do |task|
             @out.puts task.description
+            next if not @task.should_run? @context.bind
             task.setup.call(@context.bind) if task.setup
             @out.puts &quot;Enter the following code:&quot;
             @out.puts task.code_string</diff>
      <filename>Merlin/Main/Languages/Ruby/Samples/Tutorial/console_tutorial.rb</filename>
    </modified>
    <modified>
      <diff>@@ -143,6 +143,7 @@ class HtmlTutorial
             &lt;h3&gt;&lt;%= chapter.name %&gt;&lt;/h3&gt;
             &lt;p class=&quot;Body&quot;&gt;&lt;%= ToStyledHtml.convert(chapter.introduction) %&gt;&lt;/p&gt;
             &lt;% chapter.tasks.each do |task| %&gt;
+              &lt;% next if not task.should_run? @context.bind %&gt;
               &lt;% task.setup.call(@context.bind) if task.setup %&gt;
               &lt;p class=&quot;Body&quot;&gt;&lt;%= ToStyledHtml.convert(task.description) %&gt;&lt;/p&gt;
               &lt;p class=&quot;Code-Highlighted&quot;&gt;</diff>
      <filename>Merlin/Main/Languages/Ruby/Samples/Tutorial/html_tutorial.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,11 @@ require dirname + '/../tutorial.rb'
 require dirname + '/../console_tutorial'
 require dirname + '/../html_tutorial'
 
+if $LOAD_PATH.include? &quot;.&quot;
+  $LOAD_PATH.delete &quot;.&quot;
+  $LOAD_PATH &lt;&lt; Dir.pwd
+end
+
 FileUtils.cd(File.expand_path('/')) # This ensures that the tutorial can be launched from any folder
 
 describe &quot;ReplContext&quot; do
@@ -110,6 +115,10 @@ module TutorialTests
 
   def self.run_test context, chapter
     chapter.tasks.each do |task| 
+      if not task.should_run? context.bind
+        1.should == 1 # we do a dummy expectation here. TODO - There should be another way to indicate the test passed without having any expectations
+        return
+      end
       task.setup.call(context.bind) if task.setup
       result = context.interact &quot;&quot; # Ensure that the user can try unrelated code snippets without moving to the next task
       if task.code.respond_to? :to_ary
@@ -128,7 +137,11 @@ module TutorialTests
 end
 
 describe &quot;IronRubyTutorial&quot; do
-  TutorialTests.create_tests self, dirname + '/../Tutorials/ironruby_tutorial.rb'
+  TutorialTests.create_tests self, dirname + '/../Tutorials/ironruby_tutorial.rb' if defined? RUBY_ENGINE
+end
+
+describe &quot;HostingTutorial&quot; do
+  TutorialTests.create_tests self, dirname + '/../Tutorials/hosting_tutorial.rb' if defined? RUBY_ENGINE
 end
 
 describe &quot;TryRubyTutorial&quot; do</diff>
      <filename>Merlin/Main/Languages/Ruby/Samples/Tutorial/test/test_console.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,284 +17,305 @@ require &quot;stringio&quot;
 
 module Tutorial
 
-    class Summary
-      attr :title
-      attr :description
+  class Summary
+    attr :title
+    attr :description
 
-      def initialize(title, desc)
-        @title = title
-        @description = desc
-      end
+    def initialize(title, desc)
+      @title = title
+      @description = desc
+    end
 
-      def body
-        @description
-      end
+    def body
+      @description
+    end
 
-      def to_s
-        @title
-      end
+    def to_s
+      @title
     end
+  end
 
-    class Task
-        attr :description
-        attr :setup
-        attr :code
-        attr :title
-        attr :source_files # Files used by the task. The user might want to browse these files
-
-        def initialize title, description, setup, code, source_files, &amp;success_evaluator	                
-            @title = title
-            @description = description
-            @setup = setup
-            @code = code
-            @source_files = source_files
-            @success_evaluator = success_evaluator
-            
-        end
+  class Task
+    attr :description
+    attr :run_unless
+    attr :setup
+    attr :code
+    attr :title
+    attr :source_files # Files used by the task. The user might want to browse these files
+
+    def initialize title, description, run_unless, setup, code, source_files, &amp;success_evaluator	                
+      @title = title
+      @description = description
+      @run_unless = run_unless
+      @setup = setup
+      @code = code
+      @source_files = source_files
+      @success_evaluator = success_evaluator            
+    end
 
-        def success?(interaction, show_errors=false)
-            begin
-                if @success_evaluator
-                  return (@success_evaluator.call(interaction) ? true : false)
-                else
-                  old_verbose, $VERBOSE = $VERBOSE, nil                
-                  begin
-                    return eval(code_string, interaction.bind) == interaction.result
-                  ensure
-                    $VERBOSE = old_verbose
-                  end
-                end
-            rescue =&gt; e
-                warn %{success_evaluator raised error: #{e}} if show_errors
-                return false
-            end
-        end
-        
-        def code_string
-            c = code
-            c = c.to_ary.join(&quot;\n&quot;) if c.respond_to? :to_ary
-            c
-        end
+    def should_run?(bind)
+      if not @run_unless
+        return true
+      end
+      
+      begin
+        return (not @run_unless.call(bind))
+      rescue
+        return true
+      end
     end
     
-    class Chapter
-        attr :name, true # TODO - true is needed only to workaround data-binding bug
-        attr :introduction, true
-        attr :summary, true
-        attr :tasks, true
-        attr :next_item, true
-
-        def initialize name, introduction = nil, summary = nil, tasks = [], next_item = nil
-            @name = name
-            @introduction = introduction
-            @summary = summary
-            @tasks = tasks
-            @next_item = next_item
-        end
-
-        def to_s
-            @name
+    def success?(interaction, show_errors=false)
+      begin
+        if @success_evaluator
+          return (@success_evaluator.call(interaction) ? true : false)
+        else
+          old_verbose, $VERBOSE = $VERBOSE, nil                
+          begin
+            return eval(code_string, interaction.bind) == interaction.result
+          ensure
+            $VERBOSE = old_verbose
+          end
         end
+      rescue =&gt; e
+        warn %{success_evaluator raised error: #{e}} if show_errors
+        return false
+      end
+    end
+    
+    def code_string
+      c = code
+      c = c.to_ary.join(&quot;\n&quot;) if c.respond_to? :to_ary
+      c
+    end
+  end
+  
+  class Chapter
+    attr :name, true # TODO - true is needed only to workaround data-binding bug
+    attr :introduction, true
+    attr :summary, true
+    attr :tasks, true
+    attr :next_item, true
+
+    def initialize name, introduction = nil, summary = nil, tasks = [], next_item = nil
+      @name = name
+      @introduction = introduction
+      @summary = summary
+      @tasks = tasks
+      @next_item = next_item
     end
 
-    class Section
-        attr :name, true # TODO - true is needed only to workaround data-binding bug
-        attr :introduction, true
-        attr :chapters, true
-
-        def initialize name, introduction = nil, chapters = []
-            @name = name
-            @introduction = introduction
-            @chapters = chapters
-        end
+    def to_s
+        @name
+    end
+  end
 
-        def to_s
-            @name
-        end
+  class Section
+    attr :name, true # TODO - true is needed only to workaround data-binding bug
+    attr :introduction, true
+    attr :chapters, true
 
-        def first_chapter
-          @chapters.first rescue nil
-        end
+    def initialize name, introduction = nil, chapters = []
+      @name = name
+      @introduction = introduction
+      @chapters = chapters
     end
 
-    class Tutorial
-        attr :name
-        attr :file
-        attr :introduction, true
-        attr :legal_notice, true
-        attr :summary, true
-        attr :sections, true
-
-        def initialize name, file, introduction = nil, notice = nil, summary = nil, sections = []
-            @name = name
-            @file = file
-            @introduction = introduction
-            @legal_notice = notice
-            @summary = summary
-            @sections = sections
-        end
-        
-        def to_s
-            @name
-        end
+    def to_s
+      @name
+    end
 
-        def first_chapter
-          first_section.first_chapter rescue nil
-        end
+    def first_chapter
+      @chapters.first rescue nil
+    end
+  end
 
-        def first_section
-          @sections.first rescue nil
-        end
+  class Tutorial
+    attr :name
+    attr :file
+    attr :introduction, true
+    attr :legal_notice, true
+    attr :summary, true
+    attr :sections, true
+
+    def initialize name, file, introduction = nil, notice = nil, summary = nil, sections = []
+      @name = name
+      @file = file
+      @introduction = introduction
+      @legal_notice = notice
+      @summary = summary
+      @sections = sections
     end
     
-    @@tutorials = {} unless class_variable_defined? :@@tutorials
-    
-    def self.add_tutorial(tutorial)
-        @@tutorials[tutorial.file] = tutorial
+    def to_s
+      @name
     end
 
-    def self.all
-      Dir[File.expand_path(&quot;Tutorials/*_tutorial.rb&quot;, File.dirname(__FILE__))].each do |t|
-        self.get_tutorial t unless File.directory?(t)
-      end
-      @@tutorials
+    def first_chapter
+      first_section.first_chapter rescue nil
     end
 
-    def self.get_tutorial path = nil
-        if not path
-          all
-          return @@tutorials.values.first
-        end
+    def first_section
+      @sections.first rescue nil
+    end
+  end
+  
+  @@tutorials = {} unless class_variable_defined? :@@tutorials
+  
+  def self.add_tutorial(tutorial)
+    @@tutorials[tutorial.file] = tutorial
+  end
 
-        path = File.expand_path path
-        if not @@tutorials.has_key? path
-            require path
-            raise &quot;#{path} does not contains a tutorial definition&quot; if not @@tutorials.has_key? path
-        end
-        
-        return @@tutorials[path]
+  def self.all
+    Dir[File.expand_path(&quot;Tutorials/*_tutorial.rb&quot;, File.dirname(__FILE__))].each do |t|
+      self.get_tutorial t unless File.directory?(t)
     end
-    
-    class ReplContext
-        attr :scope
-        attr :bind
-        
-        def initialize
-            @partial_input = &quot;&quot;
-            @scope = Object.new
-
-            class &lt;&lt; @scope            
-                def include(*a)
-                    self.class.instance_eval { include(*a) }
-                end
-                
-                def to_s
-                    &quot;main (tutorial)&quot;
-                end
-            end
+    @@tutorials
+  end
 
-            @bind = @scope.instance_eval { binding }
-            
-            # Allow the tutorial DSL to use i.bind.foo in the success-evaluator blocks
-            def @bind.method_missing name, *args
-                if args.empty?
-                    eval name.to_s, self
-                else
-                    m = eval &quot;method #{name.inspect}&quot;, self
-                    m.call *args
-                end
-            end
-        end
-        
-        def interact input
-            # Redirect stdout. Note that this affects the entire process. If the program calls &quot;puts&quot;
-            # for some reason on another thread, the user may not expect to see the output. But it is 
-            # hard to distinguish between printing that the user initiated, and printing that the program 
-            # itself is doing.
-            output = StringIO.new
-            old_stdout, $stdout = $stdout, output
-            old_verbose, $VERBOSE = $VERBOSE, nil
-            
-            result = nil
-            error = nil
-            Thread.current[:evaluating_tutorial_input] = true
-            
-            begin
-                result = eval(@partial_input + input.to_s, @bind) # TODO - to_s should not be needed here
-            rescue Exception =&gt; error
-                raise error if error.kind_of? SystemExit
-            ensure
-                $stdout = old_stdout
-                Thread.current[:evaluating_tutorial_input] = nil
-                $VERBOSE = old_verbose
-            end
+  def self.get_tutorial path = nil
+    if not path
+      all
+      return @@tutorials.values.first
+    end
 
-            if error.kind_of? SyntaxError and error.message =~ /unexpected (\$end|END_OF_FILE)/
-                @partial_input += input
-                @partial_input += &quot;\n&quot; unless input[input.size-1] == &quot;\n&quot; # TODO - input[-1] seems to cause IndexError
-                InteractionResult.new(@bind, &quot;&quot;, nil, nil, true)
-            else
-                @partial_input = &quot;&quot;
-                InteractionResult.new(@bind, output.string, result, error)
-            end
-        end
-        
-        def reset_input
-          @partial_input = &quot;&quot;
-        end
+    path = File.expand_path path
+    if not @@tutorials.has_key? path
+      require path
+      raise &quot;#{path} does not contains a tutorial definition&quot; if not @@tutorials.has_key? path
     end
     
-    class InteractionResult
-        attr :bind
-        attr :output
-        attr :result
-        attr :error
-        
-        def initialize(bind, output, result, error = nil, partial_input = false)
-            @bind = bind
-            @output = output
-            @result = result
-            @error = error
-            @partial_input = partial_input
-            
-            raise &quot;result should be nil if an exception was raised&quot; if result and error
+    return @@tutorials[path]
+  end
+  
+  class ReplContext
+    attr :scope
+    attr :bind
+    
+    def initialize
+      @partial_input = &quot;&quot;
+      @scope = Object.new
+
+      class &lt;&lt; @scope            
+        def include(*a)
+          self.class.instance_eval { include(*a) }
         end
         
         def to_s
-            %{InteractionResult output=#{@output}, result=#{@error ? &quot;(error)&quot; : @result.inspect}, error=#{@error ? @error : &quot;(none)&quot;}}
-        end
-        
-        def result
-            raise &quot;Interaction resulted in an exception&quot; if error or @partial_input
-            @result
+          &quot;main (tutorial)&quot;
         end
-        
-        def error
-            raise &quot;Partial input received&quot; if @partial_input
-            @error
-        end
-        
-        def partial_input?
-          @partial_input
+      end
+
+      @bind = @scope.instance_eval { binding }
+      
+      # Allow the tutorial DSL to use i.bind.foo in the success-evaluator blocks
+      def @bind.method_missing name, *args
+        if args.empty?
+          eval name.to_s, self
+        else
+          m = eval &quot;method #{name.inspect}&quot;, self
+          m.call *args
         end
+      end
     end
     
-    # Simple stub class for mocking.
-    # TODO - move to a real mocking framework
-    class Stub
-        def initialize() @calls = [] end
-        
-        def respond_to?(name) true end
-        
-        def method_missing name, *args
-            @calls &lt;&lt; name
-            Stub.new
-        end
-        
-        def called?(name) @calls.include? name end
+    def interact input
+      # Redirect stdout. Note that this affects the entire process. If the program calls &quot;puts&quot;
+      # for some reason on another thread, the user may not expect to see the output. But it is 
+      # hard to distinguish between printing that the user initiated, and printing that the program 
+      # itself is doing.
+      output = StringIO.new
+      old_stdout, $stdout = $stdout, output
+      old_verbose, $VERBOSE = $VERBOSE, nil
+      
+      result = nil
+      error = nil
+      full_input = @partial_input + input.to_s
+      Thread.current[:evaluating_tutorial_input] = true
+      
+      begin
+        result = eval(full_input, @bind) # TODO - to_s should not be needed here
+      rescue Exception =&gt; error
+        raise error if error.kind_of? SystemExit
+      ensure
+        $stdout = old_stdout
+        Thread.current[:evaluating_tutorial_input] = nil
+        $VERBOSE = old_verbose
+      end
+
+      if error.kind_of? SyntaxError and error.message =~ /unexpected (\$end|END_OF_FILE)/
+        @partial_input += input
+        @partial_input += &quot;\n&quot; unless input[input.size-1] == &quot;\n&quot; # TODO - input[-1] seems to cause IndexError
+        InteractionResult.new(@bind, &quot;&quot;, &quot;&quot;, nil, nil, true)
+      else
+        @partial_input = &quot;&quot;
+        InteractionResult.new(@bind, full_input, output.string, result, error)
+      end
     end
     
-    def self.stub() Stub.new end
+    def reset_input
+      @partial_input = &quot;&quot;
+    end
+  end
+  
+  class InteractionResult
+      attr :bind
+      
+      # This should be used very sparingly. Since it checks directly what the user typed, it can have too many
+      # false positives and negatives.
+      # TODO - Remove this when there is good mocking/stubbing support
+      attr :input
+      
+      attr :output
+      attr :result
+      attr :error
+      
+      def initialize(bind, input, output, result, error = nil, partial_input = false)
+          @bind = bind
+          @input = input
+          @output = output
+          @result = result
+          @error = error
+          @partial_input = partial_input
+          
+          raise &quot;result should be nil if an exception was raised&quot; if result and error
+      end
+      
+      def to_s
+          %{InteractionResult output=#{@output}, result=#{@error ? &quot;(error)&quot; : @result.inspect}, error=#{@error ? @error : &quot;(none)&quot;}}
+      end
+      
+      def result
+          raise &quot;Interaction resulted in an exception&quot; if error or @partial_input
+          @result
+      end
+      
+      def error
+          raise &quot;Partial input received&quot; if @partial_input
+          @error
+      end
+      
+      def partial_input?
+        @partial_input
+      end
+  end
+  
+  # Simple stub class for mocking.
+  # TODO - move to a real mocking framework
+  class Stub
+      def initialize() @calls = [] end
+      
+      def respond_to?(name) true end
+      
+      def method_missing name, *args
+          @calls &lt;&lt; name
+          Stub.new
+      end
+      
+      def called?(name) @calls.include? name end
+  end
+  
+  def self.stub() Stub.new end
 
   # Utility method to verify that a handler was added to an event
   # Since there is no easily visible side-effect to adding a handler, we monkey-patch the event
@@ -410,14 +431,7 @@ class Object
     def task(options, &amp;success_evaluator)
         options = {}.merge(options)
         Thread.current[:chapter].tasks &lt;&lt; Tutorial::Task.new(
-          options[:title], options[:body], options[:setup], options[:code], options[:source_files], &amp;success_evaluator)
-    end
-
-    # This represents an operation that consists of several closely realated task. It is useful to have
-    # direct support for this so that the UI can better support it (by showing all the descriptions on the same
-    # page)
-    def multi_step_task(name, *tasks, &amp;success_evaluator)
-        raise NotImplementedError
+          options[:title], options[:body], options[:run_unless], options[:setup], options[:code], options[:source_files], &amp;success_evaluator)
     end
 end
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Samples/Tutorial/tutorial.rb</filename>
    </modified>
    <modified>
      <diff>@@ -235,7 +235,7 @@ module Wpf
   # WPF needs to do message pumping on a thread, iirb also requires a thread to read user input,
   # and all commands that interact with UI need to be executed on the message pump thread.
   def self.interact
-    raise NotImplementedError
+    raise NotImplementedError, &quot;Wpf.interact is not implemented yet&quot;
     def CallBack(function, priority = DispatcherPriority.Normal)
       Application.Current.Dispatcher.BeginInvoke(priority, System::Action[].new(function))
     end
@@ -367,7 +367,7 @@ module Wpf
     end
 
     def accept_rule(am, fragment)
-      raise NotImplementedError
+      raise NotImplementedError, &quot;accept_rule: #{fragment.to_s}&quot;
     end
     
     def convert_special(special, paragraph)</diff>
      <filename>Merlin/Main/Languages/Ruby/Samples/Tutorial/wpf.rb</filename>
    </modified>
    <modified>
      <diff>@@ -159,6 +159,7 @@ module WpfTutorial
         if @task.description
           fd = FlowDocument.from_simple_markup @task.description
           fd &lt;&lt; &quot;Full path: #{@task.source_files.tr('/', '\\')}&quot; if @task.source_files
+          return select_next_task if not @task.should_run? Window.repl.context.bind
           @task.setup.call(Window.repl.context.bind) if @task.setup
           if @task.code
             p = Paragraph.new Run.new(@task.code_string)</diff>
      <filename>Merlin/Main/Languages/Ruby/Samples/Tutorial/wpf_tutorial.rb</filename>
    </modified>
    <modified>
      <diff>@@ -167,9 +167,9 @@ namespace IronRuby.Library.Scanner {
         }
 
 #if SIGNED
-        const string RubyAssembly = @&quot;IronRuby.Libraries, Version=0.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;;
+        const string RubyAssembly = @&quot;IronRuby.Libraries, Version=0.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;;
 #else
-        const string RubyAssembly = @&quot;IronRuby.Libraries, Version=0.5.0.0, Culture=neutral&quot;;
+        const string RubyAssembly = @&quot;IronRuby.Libraries, Version=0.6.0.0, Culture=neutral&quot;;
 #endif
         internal static Dictionary&lt;Type, Type&gt; ExtensionModules;
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Utils/IronRuby.Libraries.Scanner/Program.cs</filename>
    </modified>
    <modified>
      <diff>@@ -96,15 +96,24 @@ namespace System.Runtime.CompilerServices {
             }
             Func&lt;CallSiteBinder, CallSite&gt; ctor;
 
+            MethodInfo method = null;
             var ctors = _SiteCtors;
             lock (ctors) {
                 if (!ctors.TryGetValue(delegateType, out ctor)) {
-                    MethodInfo method = typeof(CallSite&lt;&gt;).MakeGenericType(delegateType).GetMethod(&quot;Create&quot;);
-                    ctor = (Func&lt;CallSiteBinder, CallSite&gt;)Delegate.CreateDelegate(typeof(Func&lt;CallSiteBinder, CallSite&gt;), method);
-                    ctors.Add(delegateType, ctor);
+                    method = typeof(CallSite&lt;&gt;).MakeGenericType(delegateType).GetMethod(&quot;Create&quot;);
+
+                    if (TypeUtils.CanCache(delegateType)) {
+                        ctor = (Func&lt;CallSiteBinder, CallSite&gt;)Delegate.CreateDelegate(typeof(Func&lt;CallSiteBinder, CallSite&gt;), method);
+                        ctors.Add(delegateType, ctor);
+                    }
                 }
             }
-            return ctor(binder);
+            if (ctor != null) {
+                return ctor(binder);
+            }
+
+            // slow path
+            return (CallSite)method.Invoke(null, new object[] { binder });
         }
     }
 </diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/CallSite.cs</filename>
    </modified>
    <modified>
      <diff>@@ -679,7 +679,7 @@ namespace System.Dynamic {
                 : base(expression, BindingRestrictions.Empty, value) {
             }
 
-            private DynamicMetaObject GetDynamicMetaObjectForMember(string name, bool ignoreCase, DynamicMetaObject fallback) {
+            private DynamicMetaObject BindGetOrInvokeMember(DynamicMetaObjectBinder binder, string name, bool ignoreCase, DynamicMetaObject fallback, Func&lt;DynamicMetaObject, DynamicMetaObject&gt; fallbackInvoke) {
                 ExpandoClass klass = Value.Class;
 
                 //try to find the member, including the deleted members
@@ -697,43 +697,46 @@ namespace System.Dynamic {
                     value
                 );
 
-                Expression memberValue = Expression.Block(
-                    new[] { value },
-                    Expression.Condition(
-                        tryGetValue,
-                        value,
-                        fallback.Expression,
-                        typeof(object)
-                    )
+                var result = new DynamicMetaObject(value, BindingRestrictions.Empty);
+                if (fallbackInvoke != null) {
+                    result = fallbackInvoke(result);
+                }
+
+                result = new DynamicMetaObject(
+                    Expression.Block(
+                        new[] { value },
+                        Expression.Condition(
+                            tryGetValue,
+                            result.Expression,
+                            fallback.Expression,
+                            typeof(object)
+                        )
+                    ),
+                    result.Restrictions.Merge(fallback.Restrictions)
                 );
 
-                return new DynamicMetaObject(memberValue, fallback.Restrictions);
+                return AddDynamicTestAndDefer(binder, Value.Class, null, result);
             }
 
             public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
                 ContractUtils.RequiresNotNull(binder, &quot;binder&quot;);
-                DynamicMetaObject memberValue = GetDynamicMetaObjectForMember(
+                return BindGetOrInvokeMember(
+                    binder,
                     binder.Name, 
                     binder.IgnoreCase,
-                    binder.FallbackGetMember(this)
+                    binder.FallbackGetMember(this),
+                    null
                 );
-
-                return AddDynamicTestAndDefer(binder, Value.Class, null, memberValue);
             }
 
             public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
                 ContractUtils.RequiresNotNull(binder, &quot;binder&quot;);
-                DynamicMetaObject memberValue = GetDynamicMetaObjectForMember(
+                return BindGetOrInvokeMember(
+                    binder,
                     binder.Name, 
                     binder.IgnoreCase,
-                    binder.FallbackInvokeMember(this, args)
-                );
-                //invoke the member value using the language's binder
-                return AddDynamicTestAndDefer(
-                    binder,
-                    Value.Class,
-                    null,
-                    binder.FallbackInvoke(memberValue, args, null)
+                    binder.FallbackInvokeMember(this, args),
+                    value =&gt; binder.FallbackInvoke(value, args, null)
                 );
             }
 </diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/ExpandoObject.cs</filename>
    </modified>
    <modified>
      <diff>@@ -210,27 +210,32 @@ namespace System.Linq.Expressions {
         /// Creates an Expression{T} given the delegate type. Caches the
         /// factory method to speed up repeated creations for the same T.
         /// &lt;/summary&gt;
-        internal static LambdaExpression CreateLambda(Type delegateType, string name, Expression body, bool tailCall, ReadOnlyCollection&lt;ParameterExpression&gt; parameters) {
+        internal static LambdaExpression CreateLambda(Type delegateType, Expression body, string name, bool tailCall, ReadOnlyCollection&lt;ParameterExpression&gt; parameters) {
             // Get or create a delegate to the public Expression.Lambda&lt;T&gt;
             // method and call that will be used for creating instances of this
             // delegate type
-            LambdaFactory factory;
-
+            LambdaFactory fastPath;
             if (_LambdaFactories == null) {
                 // NOTE: this must be Interlocked assigment since we use _LambdaFactories for locking.
                 Interlocked.CompareExchange(ref _LambdaFactories, new CacheDict&lt;Type, LambdaFactory&gt;(50), null);
             }
 
+            MethodInfo create = null;
             lock (_LambdaFactories) {
-                if (!_LambdaFactories.TryGetValue(delegateType, out factory)) {
-                    _LambdaFactories[delegateType] = factory = (LambdaFactory)Delegate.CreateDelegate(
-                        typeof(LambdaFactory),
-                        typeof(Expression&lt;&gt;).MakeGenericType(delegateType).GetMethod(&quot;Create&quot;, BindingFlags.Static | BindingFlags.NonPublic)
-                    );
+                if (!_LambdaFactories.TryGetValue(delegateType, out fastPath)) {
+                    create = typeof(Expression&lt;&gt;).MakeGenericType(delegateType).GetMethod(&quot;Create&quot;, BindingFlags.Static | BindingFlags.NonPublic);
+                    if (TypeUtils.CanCache(delegateType)) {
+                        _LambdaFactories[delegateType] = fastPath = (LambdaFactory)Delegate.CreateDelegate(typeof(LambdaFactory), create);
+                    }
                 }
             }
 
-            return factory(body, name, tailCall, parameters);
+            if (fastPath != null) {
+                return fastPath(body, name, tailCall, parameters);
+            }
+            
+            Debug.Assert(create != null);
+            return (LambdaExpression)create.Invoke(null, new object[] { body, name, tailCall, parameters });
         }
 
         /// &lt;summary&gt;
@@ -437,7 +442,7 @@ namespace System.Linq.Expressions {
 
             Type delegateType = DelegateHelpers.MakeDelegateType(typeArgs);
 
-            return CreateLambda(delegateType, name, body, tailCall, parameterList);
+            return CreateLambda(delegateType, body, name, tailCall, parameterList);
         }
 
         /// &lt;summary&gt;
@@ -452,7 +457,7 @@ namespace System.Linq.Expressions {
             var paramList = parameters.ToReadOnly();
             ValidateLambdaArgs(delegateType, ref body, paramList);
 
-            return CreateLambda(delegateType, name, body, false, paramList);
+            return CreateLambda(delegateType, body, name, false, paramList);
         }
 
         /// &lt;summary&gt;
@@ -468,7 +473,7 @@ namespace System.Linq.Expressions {
             var paramList = parameters.ToReadOnly();
             ValidateLambdaArgs(delegateType, ref body, paramList);
 
-            return CreateLambda(delegateType, name, body, tailCall, paramList);
+            return CreateLambda(delegateType, body, name, tailCall, paramList);
         }
 
         private static void ValidateLambdaArgs(Type delegateType, ref Expression body, ReadOnlyCollection&lt;ParameterExpression&gt; parameters) {
@@ -482,7 +487,10 @@ namespace System.Linq.Expressions {
             MethodInfo mi;
             lock (_LambdaDelegateCache) {
                 if (!_LambdaDelegateCache.TryGetValue(delegateType, out mi)) {
-                    _LambdaDelegateCache[delegateType] = mi = delegateType.GetMethod(&quot;Invoke&quot;);
+                    mi = delegateType.GetMethod(&quot;Invoke&quot;);
+                    if (TypeUtils.CanCache(delegateType)) {
+                        _LambdaDelegateCache[delegateType] = mi;
+                    }
                 }
             }
 </diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/LambdaExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -571,5 +571,40 @@ namespace System.Dynamic.Utils {
         internal static Type GetNonRefType(this Type type) {
             return type.IsByRef ? type.GetElementType() : type;
         }
+
+        private static readonly Assembly _mscorlib = typeof(object).Assembly;
+        private static readonly Assembly _systemCore = typeof(Expression).Assembly;
+
+        /// &lt;summary&gt;
+        /// We can cache references to types, as long as they aren't in
+        /// collectable assemblies. Unfortunately, we can't really distinguish
+        /// between different flavors of assemblies. But, we can at least
+        /// create a whitelist for types in mscorlib (so we get the primitives)
+        /// and System.Core (so we find Func/Action overloads, etc).
+        /// &lt;/summary&gt;
+        internal static bool CanCache(this Type t) {
+            // Note: we don't have to scan base or declaring types here.
+            // There's no way for a type in mscorlib to derive from or be
+            // contained in a type from another assembly. The only thing we
+            // need to look at is the generic arguments, which are the thing
+            // that allows mscorlib types to be specialized by types in other
+            // assemblies.
+
+            var asm = t.Assembly;
+            if (asm != _mscorlib &amp;&amp; asm != _systemCore) {
+                // Not in mscorlib or our assembly
+                return false;
+            }
+
+            if (t.IsGenericType) {
+                foreach (Type g in t.GetGenericArguments()) {
+                    if (!CanCache(g)) {
+                        return false;
+                    }
+                }
+            }
+
+            return true;
+        }
     }
 }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/TypeUtils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -186,7 +186,10 @@ namespace System.Linq.Expressions.Compiler {
             }
 
             if (!curTypeInfo.TypeChain.TryGetValue(lookingUp, out nextTypeInfo)) {
-                curTypeInfo.TypeChain[lookingUp] = nextTypeInfo = new TypeInfo();
+                nextTypeInfo = new TypeInfo();
+                if (TypeUtils.CanCache(lookingUp)) {
+                    curTypeInfo.TypeChain[lookingUp] = nextTypeInfo;
+                }
             }
             return nextTypeInfo;
         }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Compiler/DelegateHelpers.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -61,7 +61,12 @@ namespace System.Dynamic.Utils {
             ParameterInfo[] pis;
             lock (_ParamInfoCache) {
                 if (!_ParamInfoCache.TryGetValue(method, out pis)) {
-                    _ParamInfoCache[method] = pis = method.GetParameters();
+                    pis = method.GetParameters();
+
+                    Type t = method.DeclaringType;
+                    if (t != null &amp;&amp; TypeUtils.CanCache(t)) {
+                        _ParamInfoCache[method] = pis;
+                    }
                 }
             }
             return pis;</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Utils/TypeExtensions.cs</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>825b81bb92b3e72ed10647646fa437b9a2a78f74</id>
    </parent>
  </parents>
  <author>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </author>
  <url>http://github.com/ironruby/ironruby/commit/fa45c98ea68bf870f5877d2e8725c2d01da5f1ea</url>
  <id>fa45c98ea68bf870f5877d2e8725c2d01da5f1ea</id>
  <committed-date>2009-06-30T23:54:34-07:00</committed-date>
  <authored-date>2009-06-30T23:54:34-07:00</authored-date>
  <message>syncing to head of tfs</message>
  <tree>0316d82e5419c01fa68ef00eb167ca01aca207c0</tree>
  <committer>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </committer>
</commit>
