Do not force the declaration unused callback params
Describe the feature
Do not force programmers to declare unused callback parameters.
Use Case
Currently we are forced to declare all params, even though we are not going to use them. This adds unnecessary "noise" to the source code:
struct Event {}
struct Element {}
fn (target Element) on_click(callback fn (event Event)) {
// ...
}
fn main() {
el := Element{}
el.on_click(fn(_ Event) {
// performs some action
})
}
Proposed approach:
struct Event {}
struct Element {}
fn (target Element) on_click(callback fn (event Event)) {
// ...
}
fn main() {
el := Element{}
// omit the unused params, as we don't need them
el.on_click(fn() {
// performs some action
})
}
Proposed Solution
The checker shouldn't complain about missing callback parameters.
Other Information
No response
Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
Version used
V 0.4.10 3f76b69
Environment details (OS name and version, etc.)
| V full version | V 0.4.10 dead5e69b44b4f8c4999ac82b730c21250cb0583.3f76b69 |
|---|---|
| OS | macos, macOS, 15.4.1, 24E263 |
| Processor | 8 cpus, 64bit, little endian, Apple M1 Pro |
| Memory | 0.16GB/16GB |
| V executable | /Users/gonzalo/Projects/Personal/v/nv/v |
| V last modified time | 2025-05-10 22:09:09 |
| V home dir | OK, value: /Users/gonzalo/Projects/Personal/v/nv |
| VMODULES | OK, value: /Users/gonzalo/.vmodules |
| VTMP | OK, value: /tmp/v_501 |
| Current working dir | OK, value: /Users/gonzalo |
| Git version | git version 2.39.1 |
| V git status | weekly.2025.19-14-g8ce8749f |
| .git/config present | true |
| cc version | Apple clang version 17.0.0 (clang-1700.0.13.3) |
| gcc version | Apple clang version 17.0.0 (clang-1700.0.13.3) |
| clang version | Apple clang version 17.0.0 (clang-1700.0.13.3) |
| tcc version | tcc version 0.9.28rc 2024-02-05 HEAD@105d70f7 (AArch64 Darwin) |
| tcc git status | thirdparty-macos-arm64 e447816c |
| emcc version | N/A |
| glibc version | N/A |
[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.
Connected to Huly®: V_0.6-22830
The feature could be extended for interfaces implementations where none of a given method arguments are used. Since v doesn't permit method overloading no two methods have the same name (different args) to cause any problem.
interface Reader {
config(params string)
read(data string)
}
struct FastReader implements Reader { }
fn (f FastReader) config() { ... } // I don't use params
fn (f FastReader) read(data string) { ... }