> I assume you meant that :lvalue() takes a parameter list.  Either a
> singleton named variable $, @, or %. 

I'm proposing that an lvalue subroutine have access to the rvalue 
assigned through a channel other than the standard argument list @_.  I 
used, as an example, an explicit named parameter to lvalue, but I could 
also see a "line-noise" variable used ($= would be perfect, but it's 
taken).

I'm proposing that that rvalue be passed by perl as a reference instead 
of as a straight $, @, or %.

I'm proposing that subs in lvalue slots that aren't lvalue subs 
generate errors.

I think that that is all I'm proposing now...

By having the rvalue passed through a separate channel, the function 
does not have to worry about wondering which of @_ (if any) is the 
rvalue.  This prevents the confusion some are worried about with the 
idea that the assigned rvalue is simply tacked onto the end.  
Specifically:

$p->name = 'Mithrandir';

would not be directly equivilant to 

$p->name('Mithrandir');

as $p->name() would be able to tell in the first case that it is called 
in lvalue-context, with 'Mithrandir' as an rvalue to assign.  It may be 
that $p->name() uses its first argument as a value to assign, but not 
necessarily.

Consider, for example, $mytensor->index(2,3,4,5,6).  Should that return 
the value of cell[2][3][4][5][6], or should it set cell[2][3][4][5] to 
6?

> Or If it makes sense even a more complex parameter list could be
> demanded.

I don't think that's necessary.  I like the idea of passing the rvalue 
in as a reference because a) references can maintain their own type 
information (as per ref()), and b) the rvalue being passed in as 
"undef" would unambiguously indicate that it was not lvalue context (a 
reference to undef is defined).  Besides, I can't imagine the rvalue 
being multiple things -- an object, yes.  A reference, yes.  An array, 
yes, a hash even.  But not multiple objects, multiple references, 
multiple arrays, or multiple hashes.

> 
> sub foo :lvalue(Dog $fido, int @array, %hash) {}
> 
> foo() = ($name, 0..10, %bar);
> 
> <chaim>
> 
> >>>>> "BB" == Buddha Buck <[EMAIL PROTECTED]> writes:
> 
> BB> sub foo : lvalue($newval) {
> BB>   # $newval is a lexical scaler in this block, initialised with a 
> BB> reference
> BB>   # to the value to be assigned to $self{foo}
> BB>   my $self = shift;
> BB>   return $self{foo} unless defined $newval; # rvalue context
> BB>   # lvalue context
> BB>   # verify new foo is in correct range
> BB>   return $self{foo} if $$newval < $MINFOO;
> BB>   return $self{foo} if $$newval > $MAXFOO;
> 
> 
> 
> -- 
> Chaim Frenkel                                      Nonlinear Knowledge, Inc.
> [EMAIL PROTECTED]                                             +1-718-236-0183

-- 
     Buddha Buck                             [EMAIL PROTECTED]
"Just as the strength of the Internet is chaos, so the strength of our
liberty depends upon the chaos and cacophony of the unfettered speech
the First Amendment protects."  -- A.L.A. v. U.S. Dept. of Justice


Reply via email to