schwern/Mite — Issue #3: Best way to get "this class is done"
Author: schwern
Created: 2011-12-09 18:19:09+00:00
State: open

Mite will work best if it knows when a class is done compiling. It needs this to know that no more attributes will be added so it can build an optimized constructor (see #2) and meta methods. I'm sure it will be useful for other things.

I have two ideas for the interface.

First is to simply have the user call a function.

use Mite::Shim;

...do your stuff...

mite_done(); # or whatever it might be called

Advantages: It's quite straightforward.

Disadvantages: It's easy to forget and hard to tell the user they forgot it.

Second is to have Mite use a block, like [Class::Meta::Express](http://search.cpan.org/perldoc?Class::Meta::Express).

use Mite::Shim;

class {
...do your stuff...
};

Advantages: There's no way to get it wrong.

Disadvantages: Everything has to be inside that block, which is aesthetically yucky.

I'm not writing this for aesthetics, so I lean towards the class block. It provides the most control, both a start and an end.