v icon indicating copy to clipboard operation
v copied to clipboard

The V playground is live

Open medvednikov opened this issue 7 years ago • 34 comments

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.

medvednikov avatar Mar 30 '19 01:03 medvednikov

This is awesome, thanks so much for putting the time into getting this up and running. Can't wait for the full release!

andrewda avatar Mar 30 '19 02:03 andrewda

Tried this:

fn main() {
	a := i8(10)
}

and it says:

Failed to launch compiled program

PavelVozenilek avatar Mar 30 '19 07:03 PavelVozenilek

Could it be that variables must be used or else it won’t compile (similar to Go)?

zac-garby avatar Mar 30 '19 08:03 zac-garby

@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.

PavelVozenilek avatar Mar 30 '19 09:03 PavelVozenilek

Ah okay, well I suppose these bugs are to be expected since it's pre-alpha.

zac-garby avatar Mar 30 '19 10:03 zac-garby

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?

ntrel avatar Mar 30 '19 13:03 ntrel

Simple example:

for (i := 0; i < 10; i++) println(i)

print:

undefined: `i`

How so simple cases didn't test?

MaxGraey avatar Mar 30 '19 21:03 MaxGraey

you need to write it like this.

fn main() {
	for i := 0; i < 10; i++ {
		println(i)
	}
}

HedariKun avatar Mar 30 '19 21:03 HedariKun

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

MaxGraey avatar Mar 30 '19 21:03 MaxGraey

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.

HedariKun avatar Mar 30 '19 21:03 HedariKun

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.

medvednikov avatar Mar 30 '19 21:03 medvednikov

oh, oki

HedariKun avatar Mar 30 '19 21:03 HedariKun

@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.

medvednikov avatar Mar 30 '19 21:03 medvednikov

@ntrel I've made the textbox a bit smaller, should fit on most >12'' laptops

medvednikov avatar Mar 30 '19 21:03 medvednikov

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.

kyubuns avatar Apr 01 '19 03:04 kyubuns

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.

wangyghy avatar Apr 01 '19 08:04 wangyghy

@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().

medvednikov avatar Apr 01 '19 11:04 medvednikov

I found the code that build failed too.

fn main() {
	for i := 0; i < 10; i++ {
		println(i)
	}
	println(i)
}

kyubuns avatar Apr 02 '19 10:04 kyubuns

i is local to the for block, you can't use it outside of it so of course the build will fail

HedariKun avatar Apr 02 '19 20:04 HedariKun

OK, I understand that the message of compilation error is not output properly now.

kyubuns avatar Apr 02 '19 23:04 kyubuns