Optional parameters referring to previous parameters?
Steven Schveighoffer
schveiguy at yahoo.com
Thu May 10 08:51:08 PDT 2012
On Thu, 10 May 2012 11:48:25 -0400, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> On Thu, 10 May 2012 10:11:35 -0400, Mafi <mafi at example.org> wrote:
>
>> Am 10.05.2012 02:16, schrieb Mehrdad:
>>> 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)
>>> {
>>> }
>>
>> Solution:
>> void process(R)(R items) {
>> process(items, items.length);
>> }
>>
>> void process(R)(R items, int maxCount);
>>
>> Is such a miminal syntactic sugar addition worth it?
>
> The same could be said for current default arg feature. If it's worth
> it there, why not here?
And BTW, it's not just sugar -- you are saving a function call and
unnecessary code space.
-Steve
More information about the Digitalmars-d
mailing list