Content deleted Content added
Added links to presently used sources |
(1) Replaced more debatable sources as references (editor comments) with others (2) Those sources retained in further reading section |
||
Line 29:
==History==
The new language was created as a result of frustration with existing languages being used for personal projects.{{sfn|Chakraborty|2023}} It was originally intended for personal use, but after being mentioned publicly and increasing interest, it was decided to make it public. V was initially created to develop a desktop messaging client named Volt.<ref name="hackaday"/> On public release, the compiler was written in V, and could [[Self-hosting (compilers)|compile itself]].{{Sfn|Rao|2021}}{{sfn|Chakraborty|2023}} Key design goals in creating V were being easy to learn and use, higher readability, fast compiling, increased safety, efficient development, [[Cross-platform software|cross-platform]] usability, improved [[C (programming language)|C]] [[interoperability]], better [[Error detection and correction|error handling]], modern features, and more maintainable software.
V is released and developed through [[GitHub]],<ref>{{cite web |url=https://ossinsight.io/analyze/vlang/v#overview |title=GitHub Programming Languages (repository details) |via=[[Open-source software|OSS]] Insight using [[TiDB]]}}</ref><ref name="hackaday"/> and maintained by developers and contributors internationally.{{Sfn|Rao|2021}} It is among the languages that have been listed on the [[TIOBE index]].<ref>{{cite web |title=TIOBE Index |url=https://www.tiobe.com/tiobe-index |publisher=[[TIOBE index|TIOBE]]|website=tiobe |archive-url=https://web.archive.org/web/20250411043213/https://www.tiobe.com/tiobe-index/|archive-date=11 April 2025|access-date=11 April 2025}}</ref>
Line 86:
=== Structs ===
Struct example:
<syntaxhighlight lang="V">
struct Point {
Line 104:
=== Heap structs ===
Structs are allocated on the stack by default. To allocate a struct on the heap and get a reference to it, the {{code|&}} prefix can be used:{{
<syntaxhighlight lang="V">
struct Point {
Line 119:
[[Method (computer programming)|Methods]] in V are functions defined with a receiver [[Parameter (computer programming)|argument]]. The receiver appears in its own argument list between the fn keyword and the method name. Methods must be in the same [[Modular programming|module]] as the receiver type.
The is_registered method has a receiver of type User named u. The convention is not to use receiver names like self or this, but preferably a short name. For example:<ref name="Knott"/>
<syntaxhighlight lang="V">
|