Optional parameters referring to previous parameters?

Steven Schveighoffer schveiguy at yahoo.com
Thu May 10 04:54:42 PDT 2012


On Wed, 09 May 2012 20:16:51 -0400, Mehrdad <wfunction at hotmail.com> wrote:

> Is this possible/should it compile?
>
> If not, should I make an enhancement request for it? It's been something  
> that would've been useful in a ton of situations for me...
>
> void process(R)(R items, size_t maxCount = items.length)
> {
> }

I *love* this idea.

Although, what happens if the expression for items is costly?  We have to  
make sure if you do:

process(someExpensiveCalculation());

it doesn't turn into:

process(someExpensiveCalculation(), someExpensiveCalculation().length);

-Steve


More information about the Digitalmars-d mailing list