Unfortunately, if I understand the compiler errors correctly, I cannot use this syntax in F #. So, since it is not supported on the side, how can I implement the goto command in F #?
As Daniel said, a label and its next block of commands can be translated into a function and its body. Then each goto becomes a function call. You must pass all local variables as arguments, since individual functions have separate scopes, and if necessary, you must add end-to-end calls from one block of commands to the next. However, tail calls are a more general concept.
An example start loop will look like this:
let rec start () = // .start start() // goto start
Note that a decent compiler will actually compile this equivalent high-level code back to jump / branch between commands in assembler. The main difference is that the frames of the stack must be reorganized, because you can overlap between completely different environments.
In addition, I believe that F #, as one of the languages in the functional programming paradigm, should be able to support higher-level transitions: where you can pass gotos to gotos.
Yes indeed. You cannot pass labels in other languages, but you can pass functions to F #, both as arguments in function calls and as return values from functions. Other languages, such as Fortran, offer settlement goto as a halfway home.
Please note that asynchronous programming is an important practical application of this method. When you call an asynchronous function, you indicate where it should enter when it exits. For example, when you make a call to start the asynchronous loading of a web page, you give it a function that will be called after the data is available (in fact, the hardware interrupt received when your last data arrives ends up turning off your high -level managed code for working with new data, which is pretty cool). Modern languages provide tools for writing asynchronous reusable code by combining these goto methods with adding code at compile time. In other languages, such as C #, you are screwed up because you want to wrap several asynchronous calls in one try..catch , but you cannot, because they actually extend to many different functions.