caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Cancel button or Status bar
@ 2008-02-16 17:01 Angela Zhu
  2008-02-16 17:26 ` [Caml-list] " Dominique Martinet
  0 siblings, 1 reply; 5+ messages in thread
From: Angela Zhu @ 2008-02-16 17:01 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

Hi,

I am using OCaml to develop an interpreter with a GUI.
In the GUI, I have a "run" button, where when you click it, it
will call a function, say "eval prog1".

Some time, the running time of "eval prog1" can be long, and
in case I want to add to the GUI the functionality that,
when click on another "cancel" button, it will terminate the
computation/evaluation immediately. (The user might don't
want to wait until the execution to finish. )

Anyone have some idea how to achieve this?

If this is impractical in OCaml, then how can I generate a
"status bar", which indicates how much of the program
(e.g. in percentage) has been finished, so you can have
an estimation on how much more you need to wait for the program
to finish.

Thanks a lot in advance!

-- 
Regards,
Angela Zhu
------------------------------------------
Dept. of CS, Rice University
http://www.cs.rice.edu/~yz2/
------------------------------------------

[-- Attachment #2: Type: text/html, Size: 1139 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Cancel button or Status bar
  2008-02-16 17:01 Cancel button or Status bar Angela Zhu
@ 2008-02-16 17:26 ` Dominique Martinet
  2008-02-16 21:49   ` Angela Zhu
  2008-02-17 22:03   ` Angela Zhu
  0 siblings, 2 replies; 5+ messages in thread
From: Dominique Martinet @ 2008-02-16 17:26 UTC (permalink / raw)
  To: Angela Zhu; +Cc: caml-list

Hello,

If it's an OCaml interpreter, I don't think there's a way to evaluate
the time needed automatically, you can compute the complexity yourself
and have a rough evaluation of the compile time, but there's no way a
computer will do it for you without actually evaluating the
expression.

The stopping is easy though; if you use a GUI you probably already
have threads (i.e. when you click on run, it will call the "eval
prog1" function in a thread, so you can keep editing inside of the
GUI). You can save the thread id when you run it, and ask to kill it
when you click on the stop button, and I don't even think it will
raise an exception.

If you're not already using threads, I'm curious and would like to
know how you plan to handle the GUI.

Regards,
Martinet Dominique

PS : O'Reilly's book is a nice place to start if you don't know much
about threads http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora175.html


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Cancel button or Status bar
  2008-02-16 17:26 ` [Caml-list] " Dominique Martinet
@ 2008-02-16 21:49   ` Angela Zhu
  2008-02-17 22:03   ` Angela Zhu
  1 sibling, 0 replies; 5+ messages in thread
From: Angela Zhu @ 2008-02-16 21:49 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1148 bytes --]

Thanks Dominique!

I was not using threads but I think it is a good idea.

Best regards,
Angela


On Feb 16, 2008 11:26 AM, Dominique Martinet <asmadeus77@gmail.com> wrote:

> Hello,
>
> If it's an OCaml interpreter, I don't think there's a way to evaluate
> the time needed automatically, you can compute the complexity yourself
> and have a rough evaluation of the compile time, but there's no way a
> computer will do it for you without actually evaluating the
> expression.
>
> The stopping is easy though; if you use a GUI you probably already
> have threads (i.e. when you click on run, it will call the "eval
> prog1" function in a thread, so you can keep editing inside of the
> GUI). You can save the thread id when you run it, and ask to kill it
> when you click on the stop button, and I don't even think it will
> raise an exception.
>
> If you're not already using threads, I'm curious and would like to
> know how you plan to handle the GUI.
>
> Regards,
> Martinet Dominique
>
> PS : O'Reilly's book is a nice place to start if you don't know much
> about threads
> http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora175.html
>

[-- Attachment #2: Type: text/html, Size: 1608 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Cancel button or Status bar
  2008-02-16 17:26 ` [Caml-list] " Dominique Martinet
  2008-02-16 21:49   ` Angela Zhu
@ 2008-02-17 22:03   ` Angela Zhu
  2008-02-18  8:24     ` Dominique Martinet
  1 sibling, 1 reply; 5+ messages in thread
From: Angela Zhu @ 2008-02-17 22:03 UTC (permalink / raw)
  To: Dominique Martinet; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1899 bytes --]

On Feb 16, 2008 11:26 AM, Dominique Martinet <asmadeus77@gmail.com> wrote:

> Hello,
>
> If it's an OCaml interpreter, I don't think there's a way to evaluate
> the time needed automatically, you can compute the complexity yourself
> and have a rough evaluation of the compile time, but there's no way a
> computer will do it for you without actually evaluating the
> expression.
>
> The stopping is easy though; if you use a GUI you probably already
> have threads (i.e. when you click on run, it will call the "eval
> prog1" function in a thread, so you can keep editing inside of the
> GUI). You can save the thread id when you run it, and ask to kill it
> when you click on the stop button, and I don't even think it will
> raise an exception.
>
> If you're not already using threads, I'm curious and would like to
> know how you plan to handle the GUI.
>
> Regards,
> Martinet Dominique
>
> PS : O'Reilly's book is a nice place to start if you don't know much
> about threads
> http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora175.html
>

Well, I followed the direction on this page, however, whenever I try to
compile using ocamlc, I got "Unbound module Thread" for the line where I
have:
"Thread.create compute ()"

Anyone knows what can be the problem here?

Here is my compiling flags:

world: $(LIBTARGETS) $(GTKSRCFILES:.ml=.cmo) src/main.ml
    ocamlc $(COMPFLAGS) -thread -custom threads.cma -cclib -lthreads -cclib
-lunix -cclib -lpthread graphics.cma $(LIBTARGETS) $(GTKSRCFILES:.ml=.cmo) \
          $(TKSRCFILES:.ml=.cmo) -o acumen src/main.ml
    @ echo " -- make world (Done)"

world.opt: $(LIBTARGETSOPT) $(GTKSRCFILES:.ml=.cmx)
    ocamlopt -thread threads.cmxa -cclib -lthreads -cclib -lunix -cclib
-lpthread $(COMPFLAGS)  $(LIBTARGETSOPT) $(GTKSRCFILES:.ml=.cmx) \
          src/main.ml -ccopt -Wl,-E -o acumen.opt
    @ echo " -- make world.opt (Done)"


Best,
Angela

[-- Attachment #2: Type: text/html, Size: 2621 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Cancel button or Status bar
  2008-02-17 22:03   ` Angela Zhu
@ 2008-02-18  8:24     ` Dominique Martinet
  0 siblings, 0 replies; 5+ messages in thread
From: Dominique Martinet @ 2008-02-18  8:24 UTC (permalink / raw)
  To: Angela Zhu; +Cc: caml-list

Hello,

Using your compiling line, I get an "reference to undefined global 'Unix'",
I've added "unix.cma" / "unix.cmxa" right before the -thread and it
then compiled just fine, and my dummy program worked. (if this still
doesn't work, mind sending everything make outputs ?)

Anyway, I don't know if you actually need all of the libraries the
book makes you load - I've only used "unix.cma -thread threads.cma"
and it worked just fine the couple of times I've used threads (change
.cma to .cmxa for ocamlopt)

Good luck,
Martinet Dominique.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-18  8:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-16 17:01 Cancel button or Status bar Angela Zhu
2008-02-16 17:26 ` [Caml-list] " Dominique Martinet
2008-02-16 21:49   ` Angela Zhu
2008-02-17 22:03   ` Angela Zhu
2008-02-18  8:24     ` Dominique Martinet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).