Generic programming ramifications of const by default

BCS ao at pathlink.com
Mon Jun 11 12:23:53 PDT 2007


Reply to Walter,

> Don Clugston wrote:
>
>> The argument seems to be that const-by-default would make the less
>> common metaprogramming case unbearably horrible. I'd like some
>> evidence for this. At least a hint that it's worse than
>> mutable-by-default.
>> 
> It's not that it's worse, it's that there's an inconsistency. Having a
> type mean one thing as a parameter and quite another as a local is
> probably going to be a problem.
> 

How bad would it be to make const by default apply to all references including 
locals?
If inout, ref, out and friends were considered to be part of the type then 
this would make thing the same everywhere.
I'd be willing to consider that even if it means that some type tuples end 
up having types in them that can only be used as parameter types.

alias T!(in int, out char[], ref float) args;
void thing(args){...}





More information about the Digitalmars-d mailing list