I would have assumed that a pre/post/invariant would not be used regularly, but rather under optional control. So this would lose that feature. <chaim> >>>>> "DC" == Damian Conway <[EMAIL PROTECTED]> writes: >> So if all I want to do is make sure that certain attributes are positive >> integers, I have to do this: >> >> [ admittedly ungainly solutions snipped ] >> >> I'd much prefer a solution where the positive-only logic was in a method >> belonging to the class, rather than being attached to afflicted attributes. >> The only ways I can see of doing this are like Gnat or Andy's RFCs. DC> TMTTWTDO! ;-) DC> What you really want is a postcondition or class invariant. DC> One that asserts that x is always positive: DC> sub new { bless {}, $_[0] } DC> sub x { lreturn $_[0]->{x} } DC> # and one of... DC> post x { $_[0]->{x} >= 0 } # post condition on x attribute DC> ensure { $_[0]->{x} >= 0 } # class invariant -- Chaim Frenkel Nonlinear Knowledge, Inc. [EMAIL PROTECTED] +1-718-236-0183
- Re: RFC 118 (v1) lvalue subs: parameters, explicit assig... Graham Barr
- Re: RFC 118 (v1) lvalue subs: parameters, explicit ... Johan Vromans
- Re: RFC 118 (v1) lvalue subs: parameters, explicit assig... Buddha Buck
- Re: RFC 118 (v1) lvalue subs: parameters, explicit ... Johan Vromans
- Re: RFC 118 (v1) lvalue subs: parameters, explicit assig... Chaim Frenkel
- Re: RFC 118 (v1) lvalue subs: parameters, explicit ... Graham Barr
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Chaim Frenkel
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Damian Conway
- Re: RFC 118 (v1) lvalue subs: parameters, expli... perl6
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Damian Conway
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Chaim Frenkel
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Damian Conway
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Chaim Frenkel
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Damian Conway
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Chaim Frenkel
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Damian Conway
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Chaim Frenkel
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Nathan Torkington
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Chaim Frenkel
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Damian Conway
- Re: RFC 118 (v1) lvalue subs: parameters, expli... Nathan Torkington