Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-28 Thread Hildo Biersma
Nathan Torkington wrote: Damian Conway writes: sub foo :lvalue { $foo } post foo { die if $foo == 5 } eval { foo() = 5; }; Postconditions on lvalue subs are not tested until the end of the complete expression in which the sub is called.

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-28 Thread Chaim Frenkel
"DC" == Damian Conway [EMAIL PROTECTED] writes: DC However, I have given thought to allowing conditions to be grouped, DC and de-activated by group. This would probably meet your need. DC pre mymethod : group("safe-coding practice") { @_ 0 } DC pre mymethod : group("debugging") { print @_,

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-28 Thread Chaim Frenkel
What you want is a pre-condition on the overridden assignment operator. What you want to do may involve having the suggested transactional variables. chaim "NT" == Nathan Torkington [EMAIL PROTECTED] writes: NT Damian Conway writes: pre mymethod : group("safe-coding practice") { @_ 0 }

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-28 Thread Nathan Torkington
Hildo Biersma writes: Hold on - post conditions are not intended to veto a change, they're intended to terminate the program if an assertion is invalid. Hence it should not matter if they run before or after assignment. Given that the assertion should be "now this and that should be true",

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-27 Thread Chaim Frenkel
"DC" == Damian Conway [EMAIL PROTECTED] writes: How would you handle differentiating between safe-coding practices and debugging type (internal) pre/post conditions? DC Why would one bother? There are two types, as I imagine them. Gatekeeper code. (Did the user send me frobnitz?) and

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-27 Thread Damian Conway
DC However, I have given thought to allowing conditions to be grouped, DC and de-activated by group. This would probably meet your need. DCpre mymethod : group("safe-coding practice") { @_ 0 } DCpre mymethod : group("debugging") { print @_, "\n"; }

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-27 Thread Nathan Torkington
Damian Conway writes: pre mymethod : group("safe-coding practice") { @_ 0 } pre mymethod : group("debugging") { print @_, "\n"; } Using these for lvalue subs doesn't give you the behaviour you want: sub foo :lvalue { $foo } post foo { die if $foo == 5 } eval { foo() =

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-24 Thread Chaim Frenkel
How would you handle differentiating between safe-coding practices and debugging type (internal) pre/post conditions? chaim "DC" == Damian Conway [EMAIL PROTECTED] writes: I would have assumed that a pre/post/invariant would not be used regularly, but rather under optional control. So this

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-23 Thread perl6
On Sun, 20 Aug 2000 16:32:16 +1000 (EST), Damian Conway said: I think we agree. $foo is a tied variable $bar is a normal variable sub zap : lvalue { return $_[0] ? $foo : $bar } zap(1) = 5; # Goes to tied variable

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-23 Thread Damian Conway
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

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-23 Thread Chaim Frenkel
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

Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes

2000-08-19 Thread Nathan Wiger
Damian Conway wrote: The lvalue accessor *shouldn't* be doing the assignment (what if an assignment isn't what I want?). The (overloaded) operator = should do the assignment. To whatever lvalue the lvalue subroutine returns. Or the "assignment" should be done by operator += or