scala / docs.scala-lang

The Scala Documentation website
http://docs.scala-lang.org
563 stars 1.03k forks source link

Add Cask tutorials #3056

Closed gkepka closed 1 month ago

gkepka commented 2 months ago

The scala-cli part needs some attention. While code compiles and starts without any problems, the process end immediately after being started. In SBT the same problem can be solved by setting fork := true, but I wasn't able to find any similar solution for scala-cli.

sjrd commented 2 months ago

The scala-cli part needs some attention. While code compiles and starts without any problems, the process end immediately after being started. In SBT the same problem can be solved by setting fork := true, but I wasn't able to find any similar solution for scala-cli.

In order to troubleshoot and isolate the problem: have you tried adding a while (true) {} loop at the end of main?

gkepka commented 2 months ago

The problem with scala-cli turned out to be caused by the difference between how files with .sc and .scala extensions are handled. It turns out that while the .scala files are executed as written, the contents of .sc files are wrapped in an auto-generated main function, ignoring all main functions defined in the code. The documentation for scala-cli makes a very good job at hiding that distinction, I managed to find it descibed here.