On Saturday, 23 August 2014 at 04:07:58 UTC, ketmar via Digitalmars-d wrote:
On Sat, 23 Aug 2014 03:50:13 +0000
via Digitalmars-d <[email protected]> wrote:

- versioning
refactor it, so that shared code goes to separate functions. nested functions especially helpful here. i'm used to this GCC extension.

- debugging (commenting out debugging code)
why comment it out? if (debug_enabled) is fine and can help when
software fails.

- virtual functions
they are either abstract or just comment out unused argument names.

- future-proof function signatures
but why? plan your API. if you need to extend it -- add new API calls.

How about unused arguments in lambda expressions?

    import std.stdio;

    void foo(int delegate(int) dlg){
        writeln(dlg(12));
    }

    void main(){
        foo((x) => x+1); // No problem here

        foo((x) => 42); // Unused argument
        //foo(() => 42); // Error
        //foo(auto) => 42); // Error

        //We have to use:
        foo((int) => 42);
    }

Since `auto` doesn't work in lambda expressions, we have to give up on type inference for arguments we are not even using!

Reply via email to