Dscanner: intentionally unused variable

SimonN eiderdaus at gmail.com
Sun Jan 7 03:41:18 UTC 2018


On Sunday, 7 January 2018 at 00:18:27 UTC, Ivan Trombley wrote:
> While working with SDL, I found that I kept using the same 
> pattern over and over:
> - Get the current clip rectangle.
> - Set a new clip rectangle.
> - restore the old clip rectangle on scope (exit).
>
> Instead of writing that code again and again, I wrote a simple 
> function that returns a struct which restores the old clip 
> rectangle in it's destructor. This works great but now dscanner 
> complains about the variable being unused.
>
> Is there a way tell dscanner that a variable is intentionally 
> unused?

Another way would be to have the RAII wrapper in a with 
statement, but it produces extra indentation, which you might not 
like:

     with (MyStruct(100, 200)) {
         // code that uses the new clip rectangle
     }

-- Simon


More information about the Digitalmars-d mailing list