Docs: Section on local variables
Steven Schveighoffer
schveiguy at yahoo.com
Thu Apr 26 12:06:27 PDT 2012
On Thu, 26 Apr 2012 14:46:38 -0400, Stewart Gordon <smjg_1998 at yahoo.com>
wrote:
> I can begin to see why it makes errors for unused variables a bad idea.
> But why no warnings? Obviously the user wouldn't like to see warnings
> thrown at them when they try using templates with such constraints. But:
>
> - The average programmer is, the vast majority of the time, not writing
> template constraints, but trying to write bug-free application code.
> - A quality compiler would swallow warnings generated by the content of
> IsExpressions, just as it already swallows errors generated by them -
> the only difference being that warnings don't cause the IsExpression to
> return false.
I think the mechanism is highly desired, but gets in the way in a select
few situations. The best answer IMO is to disable that mechanism when
it's not desired. It's then an opt-out mechanism that doesn't require
instrumenting most code.
Some ideas:
pragma(used) int x;
@used int x;
-Steve
More information about the Digitalmars-d-learn
mailing list