Feature #35
Optional warnings for fn-proc arity
Description
Add an optional warning which points out (apparently) incorrect arity.
The warning needs to be optional since it may produce "false positives"
(though the hope is that happens only rarely). The intended purposes
are to help package authors detect (arity) bugs without having to devise
test cases with 100% coverage, and to help people updating C4 code to C5
(where some functions have changed arity).
- if a fn-proc definition has been seen then (during parsing) we issue
a warning if a call has incorrect arity -- this may produce needless
warnings if the fn-proc is about to be redefined with different arity. - if no definition has been seen then we issue warnings only if two calls
have different arity -- this may produce needless warnings if the fn-proc
is later defined to accept any number of args.
Here are some examples:
The following should produce a warning:
Define f(x) If x > 0 Then Return g(x); Else Return g(x,x); EndIf; EndDefine;
The following should produce no warning:
Define g(...) Return 0; EndDefine; Define f(x) If x > 0 Then Return g(x); Else Return g(x,x); EndIf; EndDefine;
The following should produce a warning (in the defn of f):
Define g(x) Return x+1; EndDefine; Define f(x) Return g(x,x); EndDefine; Define g(x,y) Return x+y; EndDefine;
The following is a bit trickier; I think it should produce a warning:
Define f(g,x) If x > 0 Then Return g(x); Else Return g(x,x); EndIf; EndDefine;
Related issues
History
#1 Updated by Anna Maria Bigatti over 12 years ago
- Category set to Parser/Interpreter
#2 Updated by Anna Maria Bigatti about 10 years ago
- Target version set to CoCoA-5.1.0 Easter14
#3 Updated by John Abbott about 10 years ago
- Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.?.?
#4 Updated by John Abbott over 1 year ago
The idea is reasonable, but I have doubts about its genuine utility.
Even the hypothetical use-cases are not very convincing.
We have managed quite well so far without this feature.
And implementing it would likely involve considerable change to
the interpreter... something I would much rather avoid myself.
JAA suggests: reject What do you think?
#5 Updated by John Abbott over 1 year ago
- Status changed from New to Rejected
- Assignee set to John Abbott
- % Done changed from 0 to 100
- Estimated time changed from 10.00 h to 0.75 h
- we have not really ever had (in 11 years) difficulties where such a warning would have helped.
- the idea of delving deep into the interpreter is not appealing.
- Summary: benefit = little, effort = great