const challenge

Sergey Gromov snake.scaly at gmail.com
Fri Feb 1 14:41:57 PST 2008


Janice Caron Wrote:
> What I'm telling the compiler here is that the function's formal
> parameter, s, is unique at the callee site. Within the function, it
> stops being unique. Thus, within the function body, s is just a
> char[]. At the callee site, however, the compiler gets to complain if
> a non-unique type is passed to the function.

On second thoughts, why would you want a function with a unique
parameter ?  Nothing casts to unique(), so that the caller is always
required to dup() or whatever.  Why force the user do it if you can
always dup inside the function if you wish ?  I think it only complicates
the function usage.

SnakE

> 
> (My example passed it the return value from new, so it was OK).
> 
> 
> > So the only way to return a unique result from a function is to dup
> > or new or inline-construct directly within its return statement.  Other
> > return values are illegal.
> 
> Good point. It should have been
> 
>     return cast(unique)s;




More information about the Digitalmars-d mailing list