v icon indicating copy to clipboard operation
v copied to clipboard

Function argument commas

Open squidink7 opened this issue 1 year ago • 0 comments

Describe the feature

When calling function in V, each argument requires a comma to separate them. This is traditionally how most programming languages work, however it is inconsistent with struct fields and array elements which don't require comma separators. Commas are also not required when calling functions with optional arguments (parameter structs). e.g. this works:

set_option(name: 'fullscreen' value: true)

or

set_option('fullscreen', true)

but this doesn't

set_option('fullscreen' true)

Use Case

For consistency in V's syntax

Proposed Solution

This is a matter of personal preference as to whether function arguments should require commas or not, however the current situation is inconsistent, and standardising on one behaviour would be nice. I would personally vote for commas being optional but inserted with vfmt

Other Information

No response

Acknowledgements

  • [X] I may be able to implement this feature request
  • [X] This feature might incur a breaking change

Version used

master

Environment details (OS name and version, etc.)

V full version: V 0.4.4 c5a6aeb.9560d53
OS: linux, "Arch Linux"
Processor: 12 cpus, 64bit, little endian, AMD Ryzen 5 7640U w/ Radeon 760M Graphics

getwd: /home/sirsegv
vexe: /home/sirsegv/.v/v
vexe mtime: 2024-01-14 02:10:25

vroot: OK, value: /home/sirsegv/.v
VMODULES: OK, value: /home/sirsegv/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.0
Git vroot status: weekly.2023.51-191-g9560d535
.git/config present: true

CC version: cc (GCC) 13.2.1 20230801
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

[!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.

squidink7 avatar Jan 14 '24 07:01 squidink7