Questions tagged [vlang]

Questions related to the V programming language, including its syntax and its libraries.

V, inspired by Go, is a statically typed programming language that compiles to machine code. It is currently (2023-03) at version 0.3 and actively developed. It aims to be simple and as fast as C, and is targeted at systems programming, webdev, gamedev, GUI, mobile, science, embedded, etc.

53 questions
11
votes
5 answers

Command line parsing lib VLang

I want to write a command line application with the V programming language. Is there a library for command line parsing?
thinwybk
  • 4,193
  • 2
  • 40
  • 76
7
votes
1 answer

V-lang shows V panic: array index out of range error for valid indexing of array after V panic is encountered once

There is this new programming language V-lang being created by Alex Medvednikov. I'm using V-lang version 0.1.11 currently. I can declare an array in V-lang like below : a := [1,2,3] // or, mut a := [1,2,3] I tried to get the last item of this…
Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56
6
votes
1 answer

V - when memory gets freed

V does have neither a manual memory release, nor a garbage collector (reference counting) nor an owner-based mechanism like Rust. How does it decide when to free memory?
Thomas S.
  • 5,804
  • 5
  • 37
  • 72
5
votes
1 answer

How would I go about creating a static library in Vlang?

I'm relatively new to Vlang, and am trying to create a static library to try and test it out. I assume it just involves compiling to C without and then creating the static library from those C files, and calling from there, but any help would be…
5
votes
2 answers

Loop through an array in vlang

How can I loop over an array of strings on v programming language? For example: langs := ['python', 'java', 'javascript']
MosheZada
  • 2,189
  • 1
  • 14
  • 17
5
votes
1 answer

What is the variable `C` in some modules in vlib?

I was trying to figure out how to use the image library in vlib, in which there was a variable C: pub fn (img Image) tex_image_2d() { mut rgb_flag := GL_RGB if img.ext == 'png' { rgb_flag = GL_RGBA } …
Lee Garcon
  • 182
  • 10
3
votes
2 answers

How vlang compile static binary?

i have tried v -b native -prod hello.v but most modules are not supported. // hello.v println('Hello, World!') How vlang compile static binary ? Updated : i found another parameter -freestanding for static compile. $ v -freestanding hello.v $ file…
Vivian K. Scott
  • 515
  • 2
  • 5
  • 13
3
votes
1 answer

Convert a string to an array in vlang

I'm learning V, and as far as my attempts go, although a V string is an array of bytes, array methods are not applicable to strings. So I want to convert a string to an array. I have tried searching for this with no success, I found something in Go,…
Phu Nguyen
  • 43
  • 5
3
votes
3 answers

V-lang: How to send +2500 HTTP requests per second?

I am planning to write my scraper with V and i need to send estimatedly ~2500 request per second but can't figure out what am i doing wrong, it should be sending concurrently but it is deadly slow right now. Feels like i'm doing something really…
Yagiz Degirmenci
  • 16,595
  • 7
  • 65
  • 85
3
votes
2 answers

V: iterate the characters (runes) of a string

According to my understanding, a string in V is wrapped around a byte array encoded as UTF-8. That way, iterating over all string elements returns the bytes: fn main() { s := 'a string with äöü (umlauts)' println(s) for i := 0; i <…
Thomas S.
  • 5,804
  • 5
  • 37
  • 72
3
votes
1 answer

How to use C libraries in Vlang for basic statistics

I want to do basic statistics with Vlang. Can I use C libraries? For example, Apophenia: http://apophenia.info/ Or IMSL C stat library: https://docs.roguewave.com/en/imsl/c/8.6/pdf/C_Stat_library.pdf Thanks for your help.
rnso
  • 23,686
  • 25
  • 112
  • 234
3
votes
1 answer

2D array using loops, bizarre output?

This is a very basic question, but I can't figure out what is happening. I expect nested for loops in V to work like in C and other languages. Using the following for loops to build a 2D array A, I get an unexpected result. What am I doing wrong?…
AboAmmar
  • 5,439
  • 2
  • 13
  • 24
2
votes
1 answer

Vlang module calls confusion

Basics | main.v | beta.v | |__ parent | mod1.v | |__ child | mod2.v Codes: main.v import parent import parent.child as pc fn main(){ parent.name_parent() pc.name_child() } mod1.v module parent pub fn name_parent(){ …
2
votes
2 answers

Does the V language allow to extend base types?

In V language methods are defined separately from the data structures. Does the V language allow to define methods on base types, like Array? Is it possible to write my_method method like fn (array Array) my_method() { ... } list := ["a",…
Alex Craft
  • 13,598
  • 11
  • 69
  • 133
2
votes
2 answers

Can there be more than one struct member per line?

Can I have more than one struct member per line? I was making a struct. It seems like V enforces only one member per line. I don't recall seeing that mentioned anywhere. trial.v:191:2: error: unknown type `` 189 | fsize int 190 | …
aMike
  • 852
  • 5
  • 14
1
2 3 4