The V Programming Language

Simple, fast, safe language created for developing Volt, soon available for everyone.

Open source release in June 2019. Early access since April 15.
Install V from source in 0.5 seconds
wget && gcc -o v v.c

Any idea on Exception Handler?

Apr 15 · 3 min read
templarzq Jun 11 08:00
havent found any error and exception handle method in docs。Any idea?
medvednikov Jun 11 11:55
Errors are handled with option types:

There's no way to catch panics (exceptions), but there will be a way to recover, just like in Go.
medvednikov Jun 11 11:56
There's no way to catch panics *yet*.
ansarizafar Jun 18 08:30
There should be a way to catch panics (exceptions), for remote logging and cleanup.
ntrel Jun 18 16:55
I'm concerned that being able to recover from a panic and continue running the program will both add complexity to the compiler as well as encourage using panics as exceptions - isn't panic/recover essentially just throw/catch? If V supports something like `defer` or better, struct destructors (so we can manage memory automatically) then panics will make code generation (and feature design) more complex.

For logging a panic or showing a dialog to the user, all that's needed is a callback function. Only being able to register a callback that is called on panic might make the compiler's job easier in the case of code that needs to run on scope exit.
medvednikov Jun 18 22:25
That's a very good point, @ntrel.

recover() is often overused in Go.

There will be `defer` by the way.
Log in via GitHub to comment

Powered by vtalk, open-source blogging/forum software written in V