V: `fn main() {}` is no longer required in simple one file programs

Created on 1 May 2019  路  7Comments  路  Source: vlang/v

Today I re-wrote all deployment scripts from Bash to V.

I think it could be a common thing, so I decided to make one file programs a bit less verbose. Just like in Python, Swift, and many other languages you can now do

println('hello world')

instead of

fn main() {
    println('hello world')
}

This will only work if there's only one file, so you won't have Python's if __name__ == "__main__": :)

This makes learning/playing with the language a bit easier as well.

Most helpful comment

It'll be live in 0.0.8.

I felt like this was a big change, and wanted to get some feedback. Seems like nobody's against it :)

All 7 comments

Doesn't yet work for me in v0.0.7 on Linux: panic: test.v: 1 - unexpected token println

It'll be live in 0.0.8.

I felt like this was a big change, and wanted to get some feedback. Seems like nobody's against it :)

I think it's easier to solve one thing in the only way.

When is the Windows binary version scheduled to be released?

When is the Windows binary version scheduled to be released?

Tomorrow. Please use Slack/forum or create new issues for unrelated questions.

Live in 0.0.8 and in the playground.

Documentation has been updated. All examples no longer have fn main() { }.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jtkirkpatrick picture jtkirkpatrick  路  3Comments

medvednikov picture medvednikov  路  3Comments

elimisteve picture elimisteve  路  3Comments

markgraydev picture markgraydev  路  3Comments

arg2das picture arg2das  路  3Comments