On-line interpreter for Batteries
March 25, 2009 § 6 Comments
Note This entry is written on the 51st day of nationwide strike in French Universities and Research laboratories. Still no sign of negociation from the government. Liquidation of the system continues.
I am happy to announce that the repository version of OCaml Batteries Included now has a full-featured (and working) interpreter.
Toplevel (aka REPL aka interactive loop)
The toplevel has been available for some time in Batteries Included, but it has recently seen a lot of polish.
~$ rlwrap ocamlfind batteries/ocaml Objective Caml version 3.11.0 _________________________________ | | | | [| + | | Batteries Included - | |_______|_|_______________________| _________________________________ | | | | | - Type '#help;;' | | + |] |_______________________|_|_______| # open Print;; # printf p"Hello %rope!\n" r"world" ;; Hello world! - : unit = ()
Now is the right time to thank Warren Harris for the nice batteries logo and Jérémie Dimino for the new, extensible printf replacement.
Want to know more about that module?
# #browse "Print";;
module Print :
sig
type ('a, 'b, 'c) directive =
(('c Extlib.InnerIO.output -> unit) -> 'b) -> 'a
val literal : string -> ('a, 'a, 'b) directive
type pattern = string
val format :
'a Extlib.InnerIO.output ->
pattern -> ('a Extlib.InnerIO.output -> unit) array -> unit
type ('a, 'b, 'c) format =
('a, 'b, 'c) Extlib.Print.format = {
pattern : pattern;
printer : pattern -> ('a, 'b, 'c) directive;
}
val printf : ('a, unit, unit) format -> 'a
val eprintf : ('a, unit, unit) format -> 'a
val fprintf : 'a Extlib.InnerIO.output -> ('b, unit, 'a) format -> 'b
val kfprintf :
('a Extlib.InnerIO.output -> 'b) ->
'a Extlib.InnerIO.output -> ('c, 'b, 'a) format -> 'c
val rprintf : ('a, Extlib.Rope.t, string) format -> 'a
val krprintf : (Extlib.Rope.t -> 'a) -> ('b, 'a, string) format -> 'b
val sprintf : ('a, string, string) format -> 'a
val ksprintf : (string -> 'a) -> ('b, 'a, string) format -> 'b
val bprintf : Buffer.t -> ('a, unit, string) format -> 'a
val kbprintf :
(Buffer.t -> 'a) -> Buffer.t -> ('b, 'a, string) format -> 'b
end
Ah, well, the signature may be a tad complex. But in fact, this was just a shameless plug for the new #browse directive, which I personally find quite useful. As usual, for more details, use #man to open the documentation.
Script interpreter
Now, until recently, we couldn’t use Batteries Included to execute a script. This feature has recently been added by Peng Zang, Jérémie Dimino and Yours Truly.
Which means that we can now run
$ bocaml shuffle.ml Joe Jack William Averell Jack William Averell Joe
(I’m cheating here, I have an alias from bocaml to ocamlfind batteries/ocaml, I assume you should’nt have difficulties doing the same if you use Batteries often).
In other news, we’re getting very close to a Beta release. Stay tuned for more info!
Great improvments !
Btw, when seeing this title in my RSS reader, I thought there was an online (on the web) interpreter for Batteries… That would be a great idea too ! Heh.
Great job you Batteries guys.
Thanks
This certainly would be a nice idea.I believe that the ocamljava project has the necessary infrastructure. Now, if someone wants to use it with Batteries, they have our blessing.
A CGI version would be enough, probably, and much less long to write !
Quite possibly. But this would require a server — and all the server-side security issues which need to be handled for any server-run script. For the moment, I’d rather work on features and bugfixes rather than on a CGI version
How about hacking the toplevel so that it has line editing built in? That is an obvious thing to have.
This has been considered. We decided not to do this for Batteries 1.0 but after the release, we may work on it. If you wish to give us a hand, you’ll be welcome.