Generic programming ramifications of const by default
Roberto Mariottini
rmariottini at mail.com
Tue Jun 12 23:44:37 PDT 2007
Walter Bright wrote:
> Don Clugston wrote:
[...]
>> I want to create a function of the form
>>
>> A func(A.tupleof params);
>>
>> In the normal case, I don't want to modify any of the parameters. So
>> they should all be const. With mutable-by-default, it's necessary to
>> add 'const' to all of the tuple elements; it definitely adds _some_
>> complication to the most common case for metaprogramming.
>
> I think you should be able to do:
> A func(in A.tupleof params);
>
[...]
>
> 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.
What about stating that all function parameters are "in" by default?
It should be fairly clear, then.
Ciao
More information about the Digitalmars-d
mailing list