I don't have any real answers, but I'll weigh in with my opinion
anyway :-)

On Tue, Jun 20, 2006 at 10:59:01AM +0100, Daniel Hulme wrote:
> I've just thought of an interesting interaction with lvalue functions
> and call by foo. What if I want to write, say, an lvalue ?? !! function
> thus
> 
> sub cond(Bool $c, $a, $b) is rw {
>   if $c return $a else return $b;
> }
> 
> Will this fail because $a and $b are not rw? If so, will it fail at run-
> or compile-time? What about this:

That looks like it should be a compile-time failure to me.

> sub cond(Bool $c, $a is copy, $b is copy) is rw {
>   if $c return $a else return $b;
> }
> 
> Is it allowed, and if so is the behaviour to return a writeable copy of
> $a or $b? I imagine that in any case

I'd expect a compile-time failure here too, or at the very least a
warning.  Besides, returning a local copy each time hardly seems
useful, except perhaps as a way to leak memory.

> sub cond(Bool $c, $a is rw, $b is rw) is rw {
>   if $c return $a else return $b;
> }
> 
> will do what I want. 

That is what I would expect too.

> my Int $a is constant = 0;
> my Int $b is constant = 0;
> (cond(True, $a,$b))++;

We have a "constant" declarator now, so that would be 

constant Int $a = 0;
constant Int $b = 0;
(cond(True, $a,$b))++;

and that should fail at compile time because the compiler knows that
$a and $b are constant and can't be rw.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to