schwern/Mite — Issue #2: Make new() have attribute defaults embedded
Author: schwern
Created: 2011-12-09 04:04:40+00:00
State: open

The goal is for new() to honor attribute defaults without having to introspect attributes at runtime. They have to be hard coded into new(). new() has to be built after attributes are declared. I see two ways to do this.

1. Rebuild new() every time an attribute is added
2. Build new() at the end

The first could be done by putting new() in its own file. Each call to has() builds a fresh new(), with itself and all the previous attributes, overwrites the file and jams the new new() in place in the symbol table. This is a bunch of wasted work, but it's done once at build time and doesn't really matter.

The second is more sensible, but it requires Mite to know when is the "end". This could be done by something as simple as having each class call a function. `no Mite` won't work because that happens at compile time before `has` and friends get a chance to run. Knowing when the end is solves some other problems, like sticking a true value at the end of the file and creating a list of all attributes.

Both of them require that the attributes of a class be stored inside Mite so they can be listed and referenced. This will be useful both for compiling and for meta information.