"Michele Simionato" <[EMAIL PROTECTED]>:
> This is my first post to the mailing list (although some of you may have
> seen my name on comp.lang.functional or comp.lang.python) and I would
> like to document some of my frustrations while using Alice for the first
> time.
Welcome to the list, and I'm sorry to hear that you were frustrated.
> 2. Then I wrote an one-line program:
>
> $ cat hello.aml
> print "Hello World\n"
>
> and tried to run it:
>
> $ alice hello.aml
> Alice 1.4 ("Kraftwerk 'Equaliser' Album") mastered 2007/04/24
> ### loaded signature from x-alice:/lib/system/Print
> ### loaded signature from x-alice:/lib/tools/Inspector
> ### loaded signature from x-alice:/lib/distribution/Remote
> ### evaluating file /Users/micheles/md/ml/hello.aml
> val it : unit = _future
>
> As you see, "Hello World" was not printed.
Ouch. That certainly is a bug. (After some head scratching I nailed it
down to an over-optimization of a lazy future in the internals of the
toplevel - basically, making it think that you hit Ctrl-Z.)
> 3. When I saw the line "val it : unit = _future" I thought, perhaps this
> happens because of lazyness in importation of module (?), so I tried
>
> $ echo hello.aml
> await print "Hello World\n"
Yeah, no, that won't change anything. The cause is not in your code.
> 4. Then I thought "maybe I need to put a declaration" and I
> changed my program to:
Just an aside: your previous version are already considered to be
declarations.
> 5. I started looking at the documentation on the Web site and I could not
> find how to run scripts(!).
Right. Maybe I need to clarify here that Alice ML (and most other MLs,
FWIW) never was intended to be used as a scripting language. I am not sure
where you got that impression from. The model of operation is running
applications in the form of compiled components, very much like with Java
(notwithstanding the existence of an interactive toplevel for
exploration).
Maybe that explains why nobody previously reported the above bug. :-)
> There was documentation on how to compile
> components,
> so I tried that, and I changed my program to
>
> $ echo hello.aml
> structure Hello = struct
> do print "Hello World\n"
> do OS.Process.exit (OS.Process.success)
> end
>
> and I run it as follows:
>
> $ alicec hello.aml && alicerun hello.alc
> Hello World
>
> This worked, but it seems overkill to me
It more or less is the intended use. But for the purpose you have in mind
it indees is slight overkill, at least syntactically: you can compile and
invoke your previous one-liner in the same manner. But lacking a call to
exit it will not quit (explicitly exiting an application is necessary due
to the multi-threaded nature of Alice ML). So you at least have to do
print "Hello World\n"; OS.Process.exit OS.Process.success
> My expectation would be can a script can be executed by
> writing something like
>
> #!/usr/bin/env alice
> print "Hello World\n"
Well, in addition to what I said above, note that shebang is a
Unix-specific thing (and one that conflicts with SML syntax, too). One
main design goal of Alice, however, is to operate in a
platform-independent manner. So it is unlikely that we will ever add
support for that.
> For the rest, Alice looks extremely cool and I am certainly will have
> more questions to ask as I progress with it.
Thank you, and you are welcome.
Cheers,
- Andreas
_______________________________________________
alice-users mailing list
[email protected]
http://www.ps.uni-sb.de/mailman/listinfo/alice-users