我已经开始习惯于 F#实现goto
控制流的方式,但我不太确定如何处理comefrom
,比如 INTERCAL。
comefrom
是一个非常有用的构造,它允许您从标签中跳转。以下示例程序使用它来打印完整的洗手说明:
comefrom repeat
Console.Write "Lather"
Console.Write "Rinse"
repeat
其美妙之comefrom
处在于您可以在多个地方放置一个标签。
comefrom restart
Console.Write "Do you want to restart this program?"
let a = Console.ReadLine()
match a with
| "Y" -> restart
| _ -> Console.Write "Too bad! It will restart whether you like it or not!"
restart
我尝试了这两个程序,但反复无常的 F# 编译器决定让我失望。如何comefrom
在 F# 中利用?