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
HaloO,
Dave Whipp 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 c
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 at
the time
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
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 yo
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.blub
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
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
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 these two together, in a way which may be out of contex
18 matches
Mail list logo