HaloO,
David Green wrote:
I would expect all of those to work the same way in either case. That
is, anywhere the sub is used as an lvalue, it could pass the rvalue as a
special arg, not just when using "=".
I agree. But I want to stress that the big thing is that a lvalue
sub---and to a less
On 2008-Jun-2, at 3:30 pm, Jon Lang wrote:
sub foo($value?) is rw($value) { ... }
Or something to that general effect. The parameter in question must
be optional and cannot have a default value, so that a test of
whether or not the parameter is actually there can be used to
determine whe
> If a routine is rw, you may optionally define a single "slurpy scalar"
> (e.g., '*$value') in its signature.
A good start, but why limit the Lvalue to a scalar? A list l-value seems like a
pretty useful thing to me.
-Martin
-
David Green wrote:
> Jon Lang wrote:
>> If a routine is rw, you may optionally define a single "slurpy scalar"
>> (e.g., '*$value') in its signature. This scalar counts as the last
>> positional parameter, much like slurpy arrays and hashes must be declared
>> after all of the positional parameter
On 2008-Jun-1, at 1:50 pm, Jon Lang wrote:
David Green wrote:
[...] assignment should work like passing args when used on a
function. Then you can easily do whatever you want with it.
[...]
If a routine is rw, you may optionally define a single "slurpy
scalar" (e.g., '*$value') in its signa
Jon Lang wrote:
> This approach could be functionally equivalent to the "proxy object"
> approach, but with a potentially more user-friendly interface. That
> is,
>
> sub foo (*$value) { yadda }
>
> might be shorthand for something like:
>
> sub foo () is rw {
>return new Proxy:
> FETCH
David Green wrote:
> It seems overly complex to me, but perhaps I'm missing good reasons for such
> an approach. I see lvalue subs mainly as syntactic sugar:
>
>foo(42); # arg using normal syntax
>foo <== 42; # arg using feed syntax
>foo = 42; # arg using assignm
On 2008-May-27, at 9:40 am, Dave Whipp wrote:
TSa wrote:
method inch
{
yield $inch = $.mm * 25.4;
self.mm = $inch / 25.4;
}
Would you regard that as elegant?
That looks functionally incorrect to my eyes: if the caller resumes
at the time of the "yield" s
HaloO,
Dave Whipp wrote:
The sequence I was thing of is:
my $obj = Length.new;
$obj.mm = 42;
say $obj.inch; # your "Length.inch" method yields
$obj.mm = 63;
say $obj.inch; # Length.inch to resumes, overwriting $obj.mm back to 42
It seems to me that the assignment within your "inch" method will
TSa wrote:
TSa wrote:
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?
That looks functionally incorrect to my eyes: if the caller resumes a
Brandon Allbery allbery-at-kf8nh.com |Perl 6| wrote:
S06/Lvalue subroutines: "Lvalue subroutines return a proxy object
that can be assigned to. (...)"
S13/Methods: "Setter methods that expect the new value as an argument
do not fall into the well-behaved category, however."
When I take the
11 matches
Mail list logo