prefer dynamic ML_print_depth if context happens to be available;
authorwenzelm
Thu, 31 Jul 2014 22:02:21 +0200
changeset 57834 0d295e339f52
parent 57833 2c2bae3da1c2
child 57835 43ff8638c02c
prefer dynamic ML_print_depth if context happens to be available;
src/Doc/Implementation/ML.thy
src/Pure/ML-Systems/polyml.ML
src/Pure/ML/ml_context.ML
src/Pure/ML/ml_options.ML
--- a/src/Doc/Implementation/ML.thy	Thu Jul 31 21:29:31 2014 +0200
+++ b/src/Doc/Implementation/ML.thy	Thu Jul 31 22:02:21 2014 +0200
@@ -725,7 +725,7 @@
   \item @{text "@{make_string}"} inlines a function to print arbitrary values
   similar to the ML toplevel. The result is compiler dependent and may fall
   back on "?" in certain situations. The value of configuration option
-  @{attribute_ref ML_print_depth} is used implicitly at compile-time.
+  @{attribute_ref ML_print_depth} determines further details of output.
 
   \item @{text "@{print f}"} uses the ML function @{text "f: string ->
   unit"} to output the result of @{text "@{make_string}"} above,
--- a/src/Pure/ML-Systems/polyml.ML	Thu Jul 31 21:29:31 2014 +0200
+++ b/src/Pure/ML-Systems/polyml.ML	Thu Jul 31 22:02:21 2014 +0200
@@ -174,5 +174,5 @@
     ("PolyML.addPrettyPrinter (fn _ => fn _ => ml_pretty o Pretty.to_ML o (" ^ pp ^ "))");
 
 val ml_make_string =
-  "(fn x => Pretty.string_of (Pretty.from_ML (pretty_ml (PolyML.prettyRepresentation (x, Isabelle.ML_print_depth)))))";
+  "(fn x => Pretty.string_of (Pretty.from_ML (pretty_ml (PolyML.prettyRepresentation (x, Isabelle.ML_print_depth ())))))";
 
--- a/src/Pure/ML/ml_context.ML	Thu Jul 31 21:29:31 2014 +0200
+++ b/src/Pure/ML/ml_context.ML	Thu Jul 31 22:02:21 2014 +0200
@@ -94,7 +94,9 @@
     ("structure Isabelle =\nstruct\n\
      \val ML_context = Context_Position.set_visible " ^ Bool.toString visible ^
      " (ML_Context.the_local_context ());\n\
-     \val ML_print_depth = ML_Options.get_print_depth ();\n");
+     \val ML_print_depth =\n\
+     \  let val default = ML_Options.get_print_depth ()\n\
+     \  in fn () => ML_Options.get_print_depth_default default end;\n");
 
 val end_env = ML_Lex.tokenize "end;";
 val reset_env = ML_Lex.tokenize "structure Isabelle = struct end";
--- a/src/Pure/ML/ml_options.ML	Thu Jul 31 21:29:31 2014 +0200
+++ b/src/Pure/ML/ml_options.ML	Thu Jul 31 22:02:21 2014 +0200
@@ -14,6 +14,7 @@
   val print_depth_raw: Config.raw
   val print_depth: int Config.T
   val get_print_depth: unit -> int
+  val get_print_depth_default: int -> int
 end;
 
 structure ML_Options: ML_OPTIONS =
@@ -47,4 +48,9 @@
     NONE => get_default_print_depth ()
   | SOME context => Config.get_generic context print_depth);
 
+fun get_print_depth_default default =
+  (case Context.thread_data () of
+    NONE => default
+  | SOME context => Config.get_generic context print_depth);
+
 end;