Permalink
Browse files

doc for Type module

  • Loading branch information...
1 parent c576492 commit cd423cd8e3373445fd6e0b42d615ec9d7d4c2a14 @tianyicui committed Oct 4, 2012
Showing with 37 additions and 12 deletions.
  1. +1 −1 doc
  2. +36 −11 src/type.mli
View
2 doc
@@ -2,5 +2,5 @@
set -e
-ocamlbuild -no-links src/golio.docdir/index.html
+ocamlbuild -no-links -docflags -hide,Pervasives src/golio.docdir/index.html
open _build/src/golio.docdir/index.html
View
@@ -1,3 +1,8 @@
+(** All types are defined here *)
+
+(** {2 Different kinds of [value] and the runtime [env]} *)
+
+(** In evaluation, [value] is the intermediate and final result *)
type value =
| Sexp of sexp
| Func of func
@@ -8,37 +13,51 @@ type value =
| EofObject
| Void
| Thunk of user_func * value list
+
+(** [sexp], i.e., s-expression, is the input of evaluation *)
and sexp =
| Number of int
| Symbol of string
| String of string
| Bool of bool
| List of value list
| DottedList of value list * value
+
and func =
- | PrimFunc of string * (value list -> value)
+ | PrimFunc of string * (value list -> value) (* TODO: to a record *)
| UserFunc of user_func
+
and macro =
- | PrimMacro of string * (env -> sexp list -> env * value)
+ | PrimMacro of string * (env -> sexp list -> env * value) (** currently only primitive macro is implemented *) (* TODO: to a record *)
+
and port =
| InputPort of string * Lexing.lexbuf * in_channel
+ (** we need its [lexbuf] for primitive function
+ * [read], and its [in_channel] for [close-input-port] *)
| OutputPort of string * out_channel
+
and promise =
value Lazy.t
+
and chan = {
- id: int;
+ id: int; (** unique chan id *)
channel: value Event.channel;
mutable closed_flag: bool;
- (* When clients_count > 0, its value represents the number of senders
- * blocking on this channel, when clitns_count < 0, its negation represents
- * the number of receivers blocking on this channel. *)
mutable clients_count: int;
mutex: Mutex.t;
}
+(** When a [chan]'s [clients_count > 0], its value represents the number of
+ * senders blocking on this [chan], when [clients_count < 0], its negation
+ * represents the number of receivers blocking on this [chan].*)
+
+(** Runtime local environment, including the info whether we are in top level,
+* and all the non-global scope variables. *)
and env = {
top_level : bool;
+ (** whether we are in [top_level] will affect [define]'s behavior *)
locals: value ref Map.Make(String).t;
}
+
and user_func = {
params : string list;
vararg : string option;
@@ -47,16 +66,19 @@ and user_func = {
}
;;
-type lisp_error =
+(** {2 Exceptions} *)
+
+(** [lisp_error] encodes the possible runtime errors *)
+type lisp_error = (* TODO: better name? *)
| ParseError (* TODO *)
| ArgCountMismatch of arg_count_mismatch
| ArgTypeMismatch of arg_type_mismatch
| NotApplicable of value
| UnboundVar of string
| ClosedChan of chan
and arg_count_mismatch = {
- (* arg_count_expected could be like "0", "1", "2+" "1 or 2" *)
arg_count_expected : string;
+ (** could be like "0", "1", "2+" "1 or 2" *)
arg_count_got : int;
}
and arg_type_mismatch = {
@@ -66,11 +88,14 @@ and arg_type_mismatch = {
;;
exception Lisp_error of lisp_error
-exception Dead_lock
-exception Normal_exit
-exception Repl_exn of exn list
+exception Dead_lock (** raised when all fibers are waiting for [chan]*)
+exception Normal_exit (** used for notifying the repl we exited normally *)
+exception Repl_exn of exn list (** the repl can throw a single exn containing all the exceptions fibers throwed *)
;;
+(** {2 Config for Repl.repl} *)
+
+(** [repl_config] is The argument type of Repl.repl to finely tune its behavior *)
type repl_config = {
interactive : bool;
print_result : bool;

0 comments on commit cd423cd

Please sign in to comment.