On 11/10/2013 14:17, Ren? Neumann wrote:
Am 11.10.2013 15:12, schrieb Ramana Kumar:
(Ie, what I want: if is_script then main() else () )
If your main : unit -> unit (which perhaps it must be?), then main() is equivalent to the if expression above, modulo side-effects.
There is a misunderstanding here: I need the main to be run with poly --script -- which does not run it by default. But if I'd include 'main ()' in the script itself, it'd be run on compiling too (which I'd like to avoid).
I'm still unclear what you're trying to achieve. Are you trying to write a single file that can either be used as a script or run through polyc to generate a stand-alone executable? If so, you're going to have a problem with the #! line because it is only treated specially if --script is given. If you try to run the file through polyc it will complain about a syntax error.
You should be able to discover whether you are running as a script by looking for the presence of the --script option using CommandLine.arguments().
David