The V playground is live
https://vlang.io/play
This is a pre-alpha stage. The language is going to become a lot more stable in the next month.
Please report all issues via GitHub.
For security reasons imports are temporarily disabled, the size of the program is limited, and your program can't run for more than 1 second.
Coming soon: online C to V translator.
Coming not so soon: online C++ to V translator.
This is awesome, thanks so much for putting the time into getting this up and running. Can't wait for the full release!
Tried this:
fn main() {
a := i8(10)
}
and it says:
Failed to launch compiled program
Could it be that variables must be used or else it won’t compile (similar to Go)?
@zac-garby: not really, this is the same:
fn main() {
a := i8(10)
println(a)
}
Without the type cast it works.
And if there's "unused variable = bug" feature, it should be enforced only in release mode, not during the development.
Ah okay, well I suppose these bugs are to be expected since it's pre-alpha.
This is great, I've tested and updated #41, finding a bug. I also listed some issues with comment formatting there. Another issue I have is that the editor text box is too tall for my screen (1024x600), so I have to keep scrolling down to check for an error message. Could the box be say 80% of the window height instead?
Simple example:
for (i := 0; i < 10; i++) println(i)
print:
undefined: `i`
How so simple cases didn't test?
you need to write it like this.
fn main() {
for i := 0; i < 10; i++ {
println(i)
}
}
Ho, this should be legit. For example this:
mut sum := 0
mut i := 0
for (i <= 100) {
sum += i
i++
}
println(sum)// ==> "5050"
works as expected with parenthesis
fn main() {
for i := 0; (i < 10); i++ {
println(i)
}
}
this works fine. so i guess having parenthesis on declaring variable is illegal in this language, or maybe just a bug.
There are no rules or bugs here. Run this in Go and you'll get the same
syntax error: unexpected :=, expecting )
Unlike the for [expr] form, for ;; doesn't use an expression.
oh, oki
@MaxGraey you made your position on V very clear in multiple threads. You don't like it, I get it.
Please don't pollute the discussion by repeating this everywhere, especially by using language like "How so simple cases didn't test?" when using completely wrong syntax.
@ntrel I've made the textbox a bit smaller, should fit on most >12'' laptops
This language is very fun for me. 🎉
why cant build this code?
fn main() {
foo := 'bar'
types := ['game', 'web', 'tools', 'GUI', '$foo']
for typ in types {
println('Hello, $typ developers!')
}
}
struct User {
id int
}
fn main() {
user1 := User{id: 10}
user2 := User{id: 11}
user3 := User{id: 12}
users := [user1, user2, user3]
}
You just found a bug. V can't compile this program, but it should. Please create a GitHub issue.
Hello! In the example Advanced consts, I want to know what the Methods str() means. Why is it omitted in the following? I didn't find the answer in the Documentation.
@kyubuns you found a bug with arrays created with [..]. Will be fixed soon.
@wangyghy in order for println to print a struct, this struct must have a str() method. Soon each struct will have a default str().
I found the code that build failed too.
fn main() {
for i := 0; i < 10; i++ {
println(i)
}
println(i)
}
i is local to the for block, you can't use it outside of it so of course the build will fail
OK, I understand that the message of compilation error is not output properly now.