Please look at the following sample:
FUNCTION MAIN()
  LOCAL bTest := { | Param | MyFunc() }
  RETURN NIL
STATIC FUNCTION MYFUNC()
  RETURN NIL
The compiler shows this warning if /w2 or /w3 are used:
Warning W0004  Codeblock parameter: 'PARAM' declared but not used in
function: 'MAIN'
Is it expected?

Yes, it's expected.
  HB_SYMBOL_UNUSED( Param )
disables the warning without any RT overhead.

I think it is common to not reference all the codeblock parameters.

Probably yes though in some cases it may be usable and will help
to locate wrong code. To make all people happy we will have to add
compiler switch to disable this warning for codeblocks only, f.e.:
     -kB      turn off unused codeblock parameter warnings

We may, but as the one having went through almost all
the Harbour + contrib code (and own app code) to fix these,
I can tell that in most cases the extra parameters were
simply sloppy coding. The most widespread one is:
AEval( a, {|x, y| whatever(x) } ) kind of code, where
y is simply superfluous as it's not used in most such
calls, so why polluting the source with it?

In my local reference codebase, which is roughly 30MB
of Clipper code, I had to add _only one_ SYMBOL_UNUSED
to a codeblock, and even in this case (which is a
TBColumn():colorBlock value BTW), the parameter could
well be dropped, but I left it there as a sort of
self-documentation.

In any case, this should be a -w modifier option, not
a -k one.

Not for this specific case, but otherwise I think
it would be very helpful to add _more_ warnings to
spot sloppy coding, like usage of '=' in assignments,
if() inline, old-style comments (*) and there are
many others obsolete construct with superior alternatives
in the language. This is a nice way to push the language
ahead, leave old ballast and let space for new stuff
and better quality code in general. (while not breaking
compatibility)

Brgds,
Viktor

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to