Awesome Cross the Finish Line Rakudo Perl 6 Grant
This is the new addition near top of Perl 6 wiki to thank Ian Hague (and to help counter public skepticism about the prospects of Perl 6): Awesome Cross the Finish Line grant for Rakudo Perl 6 Thank you Ian Hague! * See TPF receives large donation in support of Perl 6 developmentlink. * This should see us through the first official early production-level release of Rakudo Perl 6. * Please consider following Ian's example. ** There's still a lot of additional valuable support work that could also be done on Perl 6, Parrot, key Perl 6 CPAN modules, and so on. Best regards, Conrad Schneiker www.AthenaLab.com Official Perl 6 Wiki http://www.perlfoundation.org/perl6 Official Parrot Wiki http://www.perlfoundation.org/parrot
Re: assignable mutators (S06/Lvalue subroutines)
HaloO, John M. Dlugosz wrote: I have similar thoughts. I'm thinking that some macros will aid in writing proper setters via a tie-like mechanism that don't require any core language changes, so it's not a real problem. That is, a reusable proxy class that you can construct to run the setter body code, and package it up so you write it like a method. If I get you write, you want some magic to convert $obj.attr = 42; into $obj.attr(42); so that one can write the attr method as if it had a single parameter without actually doing so. E.g. class Blah { method attr is setter { self.blahh = rhs; # rhs gives 42 above } # magically same as # method attr ($rhs) # { #self.blahh = $rhs; # } } I wonder if that couldn't simply be method attr is rw { return self.blahh; } Or am I missing something? Regards, TSa. -- The unavoidable price of reliability is simplicity -- C.A.R. Hoare Simplicity does not precede complexity, but follows it. -- A.J. Perlis 1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Re: assignable mutators (S06/Lvalue subroutines)
On 2008 May 26, at 10:19, TSa wrote: John M. Dlugosz wrote: I have similar thoughts. I'm thinking that some macros will aid in writing proper setters via a tie-like mechanism that don't require any core language changes, so it's not a real problem. That is, a reusable proxy class that you can construct to run the setter body code, and package it up so you write it like a method. I wonder if that couldn't simply be method attr is rw { return self.blahh; } Or am I missing something? What if you want to store a modification of the value? e.g. compatibility method to set a length in inches when the stored length is in millimeters. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH
Re: assignable mutators (S06/Lvalue subroutines)
HaloO, I wrote: I wonder if that couldn't simply be method attr is rw { return self.blahh; } Or am I missing something? Hmm, I forget something along the lines of method attr ($rhs) { if $rhs 10 { return self.blahh } else { return self.blubb } } which might be with my concept of equality of object as instance of a class and of a method invocation as instance of a method class written as method attr is rw { yield $rhs; # coroutine like return # we resume here after assignment if $rhs 10 { self.blahh = $rhs} else { self.blubb = $rhs} } The yield there will return the current invocation of the method as assignment proxy. The assignment operator needs to be overloaded for this type something like this multi sub infix:=(AssignmentProxy $lhs, $rhs) { $lhs.resume($rhs); } With this in place an AssignmentProxy might actually work as rvalue, too. Thus one can drop the 'is rw' from attr and all the magic is in the yield declarator/statement. class Obj { has $.foo = 'foo'; has $.blubb = 'blubb'; has $.blahh = 'blahh'; method attr { yield $rhs = self.foo; if $rhs 10 { self.blahh = $rhs} else { self.blubb = $rhs} } } my $x = Obj.new; say $x.attr; # prints 'foo' $x.attr = 42; say $x.blahh; # prints 42 So the return type of a yield might actually be ResumeProxy: sub foo ($x, $y) { my $count = 0; while $count $y - $x { yield ++count; } yield -1 while True; } say foo(7,23).resume.resume; # prints 3 my $f = foo(10,15); say $f; # prints 1 $f.resume while $f != -1; say $f; # prints -1 Regards, TSa. -- The unavoidable price of reliability is simplicity -- C.A.R. Hoare Simplicity does not precede complexity, but follows it. -- A.J. Perlis 1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Re: assignable mutators (S06/Lvalue subroutines)
HaloO, Brandon S. Allbery KF8NH wrote: What if you want to store a modification of the value? e.g. compatibility method to set a length in inches when the stored length is in millimeters. As outlined in my afterthought: class Length { has Num $.mm is rw = 0; method inch { yield $inch = $.mm * 25.4; self.mm = $inch / 25.4; } } Would you regard that as elegant? Regards, TSa. -- The unavoidable price of reliability is simplicity -- C.A.R. Hoare Simplicity does not precede complexity, but follows it. -- A.J. Perlis 1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan