Tagging of arguments ref/out, or just out
Michel Fortin
michel.fortin at michelf.com
Mon Aug 8 20:07:16 PDT 2011
On 2011-08-08 18:30:10 +0000, Kagamin <spam at here.lot> said:
> Michel Fortin Wrote:
>
>> I recently had to use getopt. You use it like that:
>>
>> bool option;
>> int counter;
>>
>> getopt(args,
>> "option|o", &option,
>> "counter|c", &counter);
>>
>> The problem is that taking addresses of a stack variable is disabled in
>> SafeD, which means getopt doesn't work in SafeD, which puts SafeD in a
>> strange position.
>
> const opts = getopt(args);
> const option = opts.get!bool("option|o");
> const counter = opts.get!int("counter|c"); // also reusable
Thanks for the tip.
That said it doesn't invalidate my complain about 'ref' and 'out' being
unusable in conjunction with type tuple arguments. If you're going to
write a function that forwards its parameters to another function,
using a type tuple to make it generic will fail in the presence of
'ref' and 'out' parameters in the wrapped function.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list