Extended Type Design.

torhu fake at address.dude
Tue Mar 20 16:13:53 PDT 2007


Andrei Alexandrescu (See Website For Email) wrote:
<snip>
> We can make "const" mean "final const" and drop "final", at the cost of 
> disallowing correct code (e.g. functions that modify their own private 
> parameters). Or we could come up with new syntax that puts "const" in a 
> different position for array, e.g.:
> 
> void Fun(const char[] const s);
> 
> After considering such alternatives, final becomes much more attractive.


I think someone, sometime mentioned changing the meaning of the 'in' 
keyword.  I guess that would have the same meaning with functions 
parameters that is planned for const now?

void Fun(in char[] s);  // Fun can't modify the array contents

void Fun(const char[] s);


// 'in' looks nice here
char* strcpy(char* to, in char* from);
char* strcpy(char* to, const char* from);

// let's say this returns the number of irreversibly converted chars, 
like iconv does.
size_t utf8ToLatin1(in char[] from, out ubyte[] to);
size_t utf8ToLatin1(const char[] from, out ubyte[] to);


One obvious problem is that in and out would not be really opposites. 
'out' and 'inout' would take the address of the argument, but 'in' does 
nothing of the sort.  Maybe that could be confusing.



More information about the Digitalmars-d mailing list