This page is no longer maintained — Please continue to the home page at www.scala-lang.org

#include for scala script ?

5 replies
dacr
Joined: 2010-09-11,
User offline. Last seen 1 week 3 days ago.
Hi,
I did some search and didn't find any default way to include a scala script file inside an other one, in order for example to share common definitions accross multiple scala scripts. So I made some experiments, and share the results there : http://www.crosson.org/2012/01/simplifying-scala-scripts.html .I was wondering If there is already some initiative about this kind of feature ? May be it is already scheduled in a next scala release ?
thanks.
Ken Scambler
Joined: 2009-11-07,
User offline. Last seen 42 years 45 weeks ago.
Re: #include for scala script ?
Isn't this what :load does?

On 27 January 2012 10:02, david crosson <crosson.david@gmail.com> wrote:
Hi,
I did some search and didn't find any default way to include a scala script file inside an other one, in order for example to share common definitions accross multiple scala scripts. So I made some experiments, and share the results there : http://www.crosson.org/2012/01/simplifying-scala-scripts.html . I was wondering If there is already some initiative about this kind of feature ? May be it is already scheduled in a next scala release ?
thanks.

dacr
Joined: 2010-09-11,
User offline. Last seen 1 week 3 days ago.
Re: #include for scala script ?

:load is only available for scala console, not for scripts.

Ken Scambler
Joined: 2009-11-07,
User offline. Last seen 42 years 45 weeks ago.
Re: #include for scala script ?
I'm pretty sure I've used it in scripts; have you tried it?  I'll check again when I get home.

On 27 January 2012 17:51, david crosson <crosson.david@gmail.com> wrote:
:load is only available for scala console, not for scripts.

Ken Scambler
Joined: 2009-11-07,
User offline. Last seen 42 years 45 weeks ago.
Re: #include for scala script ?
Aaah right.  What I had done was have a whole of script files with :load in them -- but I was loading the first one through the REPL, which meant that they were all interpreted within the REPL context.  Looks like it doesn't work when you run the script directly from the command line, as you say.

Cheers,
Ken

On 27 January 2012 18:07, Ken Scambler <ken.scambler@gmail.com> wrote:
I'm pretty sure I've used it in scripts; have you tried it?  I'll check again when I get home.

On 27 January 2012 17:51, david crosson <crosson.david@gmail.com> wrote:
:load is only available for scala console, not for scripts.


dacr
Joined: 2010-09-11,
User offline. Last seen 1 week 3 days ago.
Re: #include for scala script ?

A script #include directive implementation example :
http://www.crosson.org/2012/01/simplifying-scala-scripts-adding.html

It works fine and allow sharing code between scripts.
Regards.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland