On Mon, Sep 29, 2008 at 10:23:41PM -0400, Seth Thomas Rasmussen wrote:
> Mr. _why, will namespacing in Shoes become more plain in the future,
> or does this trickery facilitate something integral to Shoes'
> character?

Okay, well, here's what I've worked out today.

Previously, each script was executed inside an anonymous object
(Shoes::MAIN) which was just like Ruby's ruby_top_self object.
(Also known as "(main)".)

The problems with this:

 * Shoes apps could share local variables.
 * Referring to top-level constants required a :: prefix.
 * Referring to 'Widget' worked, but not 'Shoes::Widget'.

And this was further confused because, on the last point,
the opposite was true for require'd files.

The advantage was:

 * You could write `style(Link, :color => red)` in the
   Shoes.app rather than `style(Shoes::Link, :color => red)`

The new code creates an anonymous binding for each Shoes app.
The binding is inside a toplevel metaclass.  It's just another
anonymous object, but I can use 'include' to mixin the Shoes
module.

So:

 * Shoes apps cannot share local vars.
 * Referring to top-level constants does not require ::.
 * You can refer to either 'Widget' or 'Shoes::Widget'
   the Shoes module is mixed-in to the binding.
 * And, you can still write:
   `style(Link, :color => red)` 

Still unaddressed is the issue with files required externally
needing to use the full Shoes::Widget name.  I don't want to mess
with require or the top-level binding.  I'd recommend we stick with
the full Shoes::Class name whenever subclassing.

_why

Reply via email to