Hacker News new | ask | show | jobs
by isp-localhost 2182 days ago
Go's error type is something declared as being returned from a function, there's no try-catch with an exception being handed up a call stack. That's like saying ASM has exceptions because you can leave an error code in one of the registers.

The VM bit doesn't make sense to me at all. By that logic any language which implements a GC or has a native support for threads constitutes a VM?

There's no difference between a runtime and a VM? As an embedded developer I would argue that there's quite a difference between the two.

edit: Clarification on error type being "always" returned from a function.

1 comments

> Go's error type is something declared as being returned from a function, there's no try-catch with an exception being handed up a call stack. That's like saying ASM has exceptions because you can leave an error code in one of the registers.

But Go's functions "recover()" and "panic(...)" are very much like "catch" and "throw" and are all about the callstack. There's just no "try", because this special snowflake implementation of exceptions works with slightly coarser granularity than is typical (function granularity instead of block granularity), since it's living under the same roof as the error type.