Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"scala hello_world.scala" with "object extends App" appears to never execute main #4625

Closed
scabug opened this issue May 20, 2011 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented May 20, 2011

When I execute (bash command line) a simple hello_world.scala program (see below)
which uses the 2..0 "object extends App" idiom using two steps scalac hello_world.scala,
then scala hello_world, the program prints out the greeting as expected.

When I do a simple "scala hello_world.scala", the program appears to compile, then
return to the command line without having printed anything. The documentation I read
(2.9.0, various RC variants) seemed to indicate that the two ways of executing should
be the same. When I use the older idiom of an explicit main(), I get the same printout
both ways.

I appears that the delayedInit is never being called in the "scala object extends App" case.

Pardon me if this "feature" is documented and I missed it, or if I have a total misunderstanding
of intended behavior. BTW, I've written in a number of languages and Scala is great; explicit but
lightweight. Thank you all for creating & growing it.

object HwApp extends App {
printf("\nHello world App\n")
}

I can work around this in a Makefile, but it seems like either it should work or
I should learn more scala to understand why it does not.

@scabug
Copy link
Author

scabug commented May 20, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4625?orig=1
Reporter: Lee Tibbert (leet)
Affected Versions: 2.9.0

@scabug
Copy link
Author

scabug commented Jun 10, 2011

@paulp said:
The code which finds the main method is not sophisticated and doesn't see inherited mains. In principle it should be made to work.

@scabug
Copy link
Author

scabug commented May 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants