[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Caml-list] Release 3.09.1



On Fri, 2006-01-06 at 21:44 -0500, Eric Cooper wrote:
> On Sat, Jan 07, 2006 at 01:37:18PM +1100, skaller wrote:
> > I cannot and do not want to error out code that choses to name
> > unused function parameters, for example: one could even say that in
> > the presence of type inference this is a good thing.
> 
> BTW, you can use a sensible name prefixed with an underscore to
> prevent the compiler from complaining:
> 
>     let foo n _unused1 _unused2 = n + 1

Thanks for this info, I didn't know leading underscore suppressed
the warning. However it wouldn't be convenient to do this. I have
functions like this:

	let f syms x = ... 

where the name 'syms' is conventional and describes the argument
type, and so using that name is quite important to readability.

In other cases, unused arguments *should* be named, and need
*particular* names specifically to HIDE arguments of outer
scopes that are used .. in order that a change which requires
the symbol be used refer to the correct name: if you used
a wildcard you'd be able to see through to the outer name
and refer to the wrong thing by mistake.. I've actually
had several errors like this which compiled but didn't
run correctly -- very hard to debug :)


Somehow .. perfectly precise code is often BAD code:
the ability of code to withstand modification or not 
is also a quality factor. Hard to say which way to
go sometimes, for example I have learned to write

	for(i=0; i != 10; ++i)

in C, rather than using i <10, precisely because it is
fragile .. we WANT the code to break rather than fail
silently with an incorrect result. Interesting kind of
issue, but the bottom line is quality is hard to judge,
and style rules sometimes help and sometimes get in the
way .. so -warn-error is a risky thing for quality 
assurance.

I feel a bit weird arguing against an idea that basically
I agree with .. I like to turn most warnings into errors,
but sometimes compilers are a bit over-exuberant with their
warnings -- indeed language standards are often too hard
with what they consider errors ;(

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net



Reply to: