digitalmars.D.learn - auto in function signature for defaulted arguments?
- bearophile (11/11) Jun 27 2013 Sometimes I have code like this:
- Andrej Mitrovic (5/8) Jun 27 2013 I've wanted this too once. Although there's a tradeoff here, now the
- bearophile (4/6) Jun 27 2013 Do you have a realistic use case for generic code?
- Andrej Mitrovic (2/5) Jun 27 2013 No, I'm just speaking out loud about the possibility.
Sometimes I have code like this: struct VeryLongNamedStruct {} void foo(in VeryLongNamedStruct x = VeryLongNamedStruct(1)) {} void main() {} Or even: void bar(in TupleFoo x = TupleFoo(TupleBar(2), TupleSpam(3))) {} So is it a good idea to allow "auto" in the function signature for the arguments that have a default value? void foo(in auto x = VeryLongNamedStruct(1)) {} Bye, bearophile
Jun 27 2013
On 6/27/13, bearophile <bearophileHUGS lycos.com> wrote:So is it a good idea to allow "auto" in the function signature for the arguments that have a default value? void foo(in auto x = VeryLongNamedStruct(1)) {}I've wanted this too once. Although there's a tradeoff here, now the user has to work more to figure out what type it can pass to the foo function. On the other hand it could be useful in non-public and generic code.
Jun 27 2013
Andrej Mitrovic:On the other hand it could be useful in non-public and generic code.Do you have a realistic use case for generic code? Bye, bearophile
Jun 27 2013
On 6/27/13, bearophile <bearophileHUGS lycos.com> wrote:No, I'm just speaking out loud about the possibility.On the other hand it could be useful in non-public and generic code.Do you have a realistic use case for generic code?
Jun 27 2013