* [Caml-list] # eval line; (?)
@ 2002-05-09 13:58 Coletta Rémi
2002-05-09 19:03 ` Warp
2002-05-09 19:22 ` Sami Mäkelä
0 siblings, 2 replies; 7+ messages in thread
From: Coletta Rémi @ 2002-05-09 13:58 UTC (permalink / raw)
To: caml-list
Hello,
# line;;
- : string = "let b = 1;;"
# b;;
^
Unbound value b
I'm looking for a function like "eval" in LISP, that does
# eval line;
-: int = 1
#b;;
- : int = 1
Thanks,
--
Remi COLETTA
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] # eval line; (?)
2002-05-09 13:58 [Caml-list] # eval line; (?) Coletta Rémi
@ 2002-05-09 19:03 ` Warp
2002-05-09 19:22 ` Sami Mäkelä
1 sibling, 0 replies; 7+ messages in thread
From: Warp @ 2002-05-09 19:03 UTC (permalink / raw)
To: OCaml
> Hello,
>
> # line;;
> - : string = "let b = 1;;"
>
> # b;;
> ^
> Unbound value b
>
> I'm looking for a function like "eval" in LISP, that does
This function does NOT exists, for many reasons ( including security and
typing ).
Nicolas Cannasse
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] # eval line; (?)
2002-05-09 13:58 [Caml-list] # eval line; (?) Coletta Rémi
2002-05-09 19:03 ` Warp
@ 2002-05-09 19:22 ` Sami Mäkelä
2002-05-10 18:02 ` Chris Hecker
1 sibling, 1 reply; 7+ messages in thread
From: Sami Mäkelä @ 2002-05-09 19:22 UTC (permalink / raw)
To: Coletta Rémi; +Cc: caml-list
> # line;;
> - : string = "let b = 1;;"
>
> # b;;
> ^
> Unbound value b
>
> I'm looking for a function like "eval" in LISP, that does
>
> # eval line;
> -: int = 1
>
> #b;;
> - : int = 1
Try:
let eval str =
Toploop.execute_phrase true Format.std_formatter
(!Toploop.parse_toplevel_phrase (Lexing.from_string str));;
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] # eval line; (?)
2002-05-09 19:22 ` Sami Mäkelä
@ 2002-05-10 18:02 ` Chris Hecker
2002-05-10 19:27 ` Sami Mäkelä
0 siblings, 1 reply; 7+ messages in thread
From: Chris Hecker @ 2002-05-10 18:02 UTC (permalink / raw)
To: Sami Mäkelä, Coletta Rémi; +Cc: caml-list
> Try:
>let eval str =
> Toploop.execute_phrase true Format.std_formatter
> (!Toploop.parse_toplevel_phrase (Lexing.from_string str));;
I think he wants the variable to be bound into the current toplevel
environment, which this doesn't do:
# b;;
Characters 0-1:
Unbound value b
# let eval str =
Toploop.execute_phrase true Format.std_formatter
(!Toploop.parse_toplevel_phrase (Lexing.from_string str));;
val eval : string -> bool = <fun>
# eval "let b = 1;;";;
val b : int = 1
- : bool = true
# b;;
Characters 0-1:
Unbound value b
# eval "b;;";;
Uncaught exception: Typecore.Error(_, _).
Unless I made a mistaken assumption?
I don't think there's any way to bind it into the current toplevel, but
maybe you could dynamically load a module or hack something with #use or
something. I'm using 3.01 still, so maybe this is different on 3.04.
Chris
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [Caml-list] # eval line; (?)
@ 2002-05-10 20:39 Gurr, David (MED, self)
2002-05-16 20:23 ` Coletta Rémi
0 siblings, 1 reply; 7+ messages in thread
From: Gurr, David (MED, self) @ 2002-05-10 20:39 UTC (permalink / raw)
To: Sami Mäkelä, Coletta Rémi; +Cc: caml-list
I think that there is a small catch. I think that the definition of
eval is correct, but that if you use it in a toplevel loop, then it
will fail because of the parser not reenterant. -D
> -----Original Message-----
> From: Sami Mäkelä [mailto:sajuma@utu.fi]
> Sent: Thursday, May 09, 2002 12:23 PM
> To: Coletta Rémi
> Cc: caml-list@inria.fr
> Subject: Re: [Caml-list] # eval line; (?)
>
>
> > # line;;
> > - : string = "let b = 1;;"
> >
> > # b;;
> > ^
> > Unbound value b
> >
> > I'm looking for a function like "eval" in LISP, that does
> >
> > # eval line;
> > -: int = 1
> >
> > #b;;
> > - : int = 1
>
> Try:
>
> let eval str =
> Toploop.execute_phrase true Format.std_formatter
> (!Toploop.parse_toplevel_phrase (Lexing.from_string str));;
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives:
> http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:
http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] # eval line; (?)
2002-05-10 20:39 Gurr, David (MED, self)
@ 2002-05-16 20:23 ` Coletta Rémi
0 siblings, 0 replies; 7+ messages in thread
From: Coletta Rémi @ 2002-05-16 20:23 UTC (permalink / raw)
To: caml-list
On Fri, 10 May 2002 15:39:50 -0500
"Gurr, David (MED, self)" <David.Gurr@med.ge.com> wrote:
>
>I think that there is a small catch. I think that the definition of
>eval is correct, but that if you use it in a toplevel loop, then it
>will fail because of the parser not reenterant. -D
>
Exactly,
But i don't know if someone has post a solution (because the archive page
http://caml.inria.fr/archives/200205/threads.html look's like not to be refresh :-(
I've got 2 process:
- the first one write into a fffo expression like "{tab = [| 1;1 |]; valeur = false}"
- the second one has to read this expression...
I think this can be do by a "hand-made parser" but an "Lisp-like" "eval" were
a good idea.
PS: please, excuse my english speaking :-(
--
Remi COLETTA
www.coletta.free.fr
.-.
/v\ TUX
// \\ POWERED
/( )\
^^-^^
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-05-16 20:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-09 13:58 [Caml-list] # eval line; (?) Coletta Rémi
2002-05-09 19:03 ` Warp
2002-05-09 19:22 ` Sami Mäkelä
2002-05-10 18:02 ` Chris Hecker
2002-05-10 19:27 ` Sami Mäkelä
2002-05-10 20:39 Gurr, David (MED, self)
2002-05-16 20:23 ` Coletta Rémi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox