[Nickle]Re: Nickle: array assignment?
Keith Packard
keithp@keithp.com
Mon, 19 Feb 2001 18:45:46 -0800
Around 21 o'clock on Feb 17, Barton C Massey wrote:
> Right now, after
> a = [3]{1,2,3};
> b = a;
> b is a reference to the same array as a. Is this the
> "right" semantic? If so, is there any way to make b be a
> copy of a, which is also often desirable? In particular,
> if a is immutable, can I make b be a mutable copy of a?
>
> I hate deep-copy/shallow-copy semantics.
I did shallow copy so that function arguments would work like C does.
Alternatively, we could always do deep-copy and pass references around
instead. But the additional syntax required is a pain:
function bar (ref a)
{
(*a)[0] = 12;
}
array q = [3];
bar(&q);
Oh, I know, I know! We could use C++ semantics; I love them:
foo (int &a)
{
a = 27;
}
bar ()
{
int b;
foo (b);
return b;
}
Those seem so clear and unambiguous to me.
Are there better boxing/unboxing syntax schemes?
keithp@keithp.com XFree86 Core Team SuSE, Inc.