On Sep 29, 2008, at 09:31, David E. Wheeler wrote:

Eric, are you going to commit your patch so I can finish re-doing my and resubmitting it?

Also, have we settled on 4- or 2- space indents yet? At this point, though I prefer 4-space, I don't really care enough to press it, as long as tabs go away.

Here's the updated patch. I've used 2-space indents for now. All tests pass save those that also fail without the patch (aforementioned use of properties as class attributes; Eric made them fail in r11891, I believe. It otherwise makes precisely the same functional changes as before, namely:

* Default values passed to `add_property()` may now be code references, in which case the return value of the code ref will be used as the default.

* Add property now has the previously-discussed interface. The `default` argument or parameter can be a code reference, as just described. The `check` parameter is an optional code reference that must return true if a new value is valid, and false it is invalid. If the property is a hash, the entire hash will be verified once new values have been assigned.

* Added `property_error()`. This method should be called by check code refs that detect invalid values. Right now it just calls `die`. Let me know if it should do something different.

* Made use of the new functionality when defining the "installdirs" property, per Schwern's example. What other properties should we check?

* Added tests for this stuff.

* Documented `add_property()` and `property_error()`. I had no idea that `add_property()` was never documented before! Check those docs for more details on how `add_property()` works.

Best,

David

Attachment: add_property.patch
Description: Binary data


Reply via email to