On Wed, Aug 20, 2008 at 08:38:04PM +1000, Bluebie, Jenna wrote:
> It is possible to both change the binding, and run a proc in some other place 
> without changing it's binding permanently (as with instance_eval and 
> friends) for much hacky fun. Markaby and Shoes make use of that freedom a 
> lot to do a lot of their trickery.

However.  One caveat.  Shoes does no instance_eval generally, since
it turned out to be so confusing in Markaby.  Maybe very early on,
but not now.

How was it confusing?  Well, instance_eval changes `self`.  Which
means instance variables won't pass from one block to the next.  It
just makes things weird.

So, Shoes keeps track of which slot is open for editing and, when an
element is added, it gets added to the open slot.

  Shoes.app do
    stack do
      flow do
        para "Name"    # the 'flow' is the open slot
        edit_line      # so these get added to that
      end
    end
  end

The `self` throughout all of this is the Shoes::App object.  So,
when you set instance vars, they get set on the Shoes::App.  (Unless
you're in a url-style Shoes subclass.  Then they get set on an
object of that type.)

_why

Reply via email to