src/Doc/IsarImplementation/ML.thy
changeset 51636 e49bf0be79ba
parent 51295 71fc3776c453
child 52416 383ffec6a548
equal deleted inserted replaced
51635:e8e027aa694f 51636:e49bf0be79ba
   738   itself, i.e.\ function @{ML foo} is available in the present context
   738   itself, i.e.\ function @{ML foo} is available in the present context
   739   of this paragraph.
   739   of this paragraph.
   740 *}
   740 *}
   741 
   741 
   742 
   742 
       
   743 subsection {* Printing ML values *}
       
   744 
       
   745 text {* The ML compiler knows about the structure of values according
       
   746   to their static type, and can print them in the manner of the
       
   747   toplevel loop, although the details are non-portable.  The
       
   748   antiquotation @{ML_antiquotation_def "make_string"} provides a
       
   749   quasi-portable way to refer to this potential capability of the
       
   750   underlying ML system in generic Isabelle/ML sources.  *}
       
   751 
       
   752 text %mlantiq {*
       
   753   \begin{matharray}{rcl}
       
   754   @{ML_antiquotation_def "make_string"} & : & @{text ML_antiquotation} \\
       
   755   \end{matharray}
       
   756 
       
   757   @{rail "
       
   758   @@{ML_antiquotation make_string}
       
   759   "}
       
   760 
       
   761   \begin{description}
       
   762 
       
   763   \item @{text "@{make_string}"} inlines a function to print arbitrary
       
   764 values similar to the ML toplevel.  The result is compiler dependent
       
   765 and may fall back on "?" in certain situations.
       
   766 
       
   767   \end{description}
       
   768 *}
       
   769 
       
   770 text %mlex {* The following artificial example shows how to produce
       
   771   ad-hoc output of ML values for debugging purposes.  This should not
       
   772   be done in production code, and not persist in regular Isabelle/ML
       
   773   sources.  *}
       
   774 
       
   775 ML {*
       
   776   val x = 42;
       
   777   val y = true;
       
   778 
       
   779   writeln (@{make_string} {x = x, y = y});
       
   780 *}
       
   781 
       
   782 
   743 section {* Canonical argument order \label{sec:canonical-argument-order} *}
   783 section {* Canonical argument order \label{sec:canonical-argument-order} *}
   744 
   784 
   745 text {* Standard ML is a language in the tradition of @{text
   785 text {* Standard ML is a language in the tradition of @{text
   746   "\<lambda>"}-calculus and \emph{higher-order functional programming},
   786   "\<lambda>"}-calculus and \emph{higher-order functional programming},
   747   similar to OCaml, Haskell, or Isabelle/Pure and HOL as logical
   787   similar to OCaml, Haskell, or Isabelle/Pure and HOL as logical