Skip to content

dotr should exec scripts #4747

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

Closed
tisonkun opened this issue Jul 1, 2018 · 8 comments · Fixed by #10491
Closed

dotr should exec scripts #4747

tisonkun opened this issue Jul 1, 2018 · 8 comments · Fixed by #10491
Assignees
Milestone

Comments

@tisonkun
Copy link

tisonkun commented Jul 1, 2018

Consider script below

// script.scala
def truth(): Int = 42
println(truth())

In Scala, we can use command scala to exec it directly.

$ scala script.scala 
42
$ 

But dotr could not identify bare script, and it complains

$ dotr script.scala 
Error: Could not find or load main class script.scala
$ 
@liufengyun liufengyun self-assigned this Jul 6, 2018
@tisonkun
Copy link
Author

tisonkun commented Sep 1, 2018

@smarter reminded of this issue, I wonder if dotty plans to support scripting. Sure it could be a compiled lang, but for wide use it would be awesome if support scripting. However, it would introduce extra complexity. What is the trade off dev team think of?

@liufengyun
Copy link
Contributor

liufengyun commented Sep 1, 2018

@tisonkun Initially, we plan to support features existent in Scalac. If you are looking for a scripting solution for Scala (e.g. handles dependencies), you can have a look at Ammonite.

@tisonkun
Copy link
Author

@liufengyun how's it going? Is it planned to be implemented in the future or we just reject it?

@liufengyun
Copy link
Contributor

@tisonkun This is definitely to be supported. There are also some thoughts to make the scripts more powerful by standardizing some features in Ammonite:

However, we are currently focusing on other priorities. External contributions are welcome.

/cc : @AleksanderBG

@deanwampler
Copy link
Contributor

+1 for fixing this. It's a major pain for us book writers who have most examples in script form.

@philwalk
Copy link
Contributor

I have never been able to get ammonite to work in windows, whereas generic scala scripting works just fine, and I use it quite a bit. My preference would be for script syntax to be 100% scalac compatible without special "script-only" syntax, which implies (among other things) that the compiler ignore a hash-bang line, and that scripts be permitted to declare a package. I would be willing to contribute to this, fwiw.

@liufengyun
Copy link
Contributor

@philwalk I think initially 100% scalac compatibility makes perfect sense. Contributions on this will be much appreciated.

@liufengyun liufengyun removed their assignment Oct 30, 2020
@bishabosha
Copy link
Member

bump this issue

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

Successfully merging a pull request may close this issue.

7 participants