dscanner and ref parameters

mark mark at qtrac.eu
Sun Feb 23 09:03:56 UTC 2020


I use dscanner to lint my code and find it helpful.

However, in GtkD there are several functions which take ref args, 
and these confuse dscanner.

For example:

         uint kv;
         event.getKeyval(kv); // ref arg is updated here

dscanner incorrectly (but understandably) reports:

     Variable kv is never modified and could have been declared 
const or immutable.

If D allowed the _optional_ use of ref at the call site:

         uint kv;
         event.getKeyval(ref kv);

Then this would not only help dscanner, but also make it clear to 
programmers that the argument could be modified.

(This is done in Rust with f(&mut arg), and I certainly find it 
helpful.)



More information about the Digitalmars-d-learn mailing list