208 formally-checked manner. |
208 formally-checked manner. |
209 |
209 |
210 \begin{matharray}{rcl} |
210 \begin{matharray}{rcl} |
211 @{ML_antiquotation_def "scala_function"} & : & \<open>ML_antiquotation\<close> \\ |
211 @{ML_antiquotation_def "scala_function"} & : & \<open>ML_antiquotation\<close> \\ |
212 @{ML_antiquotation_def "scala"} & : & \<open>ML_antiquotation\<close> \\ |
212 @{ML_antiquotation_def "scala"} & : & \<open>ML_antiquotation\<close> \\ |
|
213 @{ML_antiquotation_def "scala_thread"} & : & \<open>ML_antiquotation\<close> \\ |
213 \end{matharray} |
214 \end{matharray} |
214 |
215 |
215 \<^rail>\<open> |
216 \<^rail>\<open> |
216 (@{ML_antiquotation scala_function} | @{ML_antiquotation scala}) |
217 (@{ML_antiquotation scala_function} | |
217 @{syntax embedded} |
218 @{ML_antiquotation scala} | |
|
219 @{ML_antiquotation scala_thread}) @{syntax embedded} |
218 \<close> |
220 \<close> |
219 |
221 |
220 \<^descr> \<open>@{scala_function name}\<close> inlines the checked function name as ML string |
222 \<^descr> \<open>@{scala_function name}\<close> inlines the checked function name as ML string |
221 literal. |
223 literal. |
222 |
224 |
223 \<^descr> \<open>@{scala name}\<close> invokes the checked function via the PIDE protocol. In |
225 \<^descr> \<open>@{scala name}\<close> and \<open>@{scala_thread name}\<close> invoke the checked function via |
224 Isabelle/ML this appears as a function of type |
226 the PIDE protocol. In Isabelle/ML this appears as a function of type |
225 \<^ML_type>\<open>string -> string\<close>, which is subject to interrupts within the ML |
227 \<^ML_type>\<open>string -> string\<close>, which is subject to interrupts within the ML |
226 runtime environment as usual. A \<^scala>\<open>null\<close> result in Scala raises an |
228 runtime environment as usual. A \<^scala>\<open>null\<close> result in Scala raises an |
227 exception \<^ML>\<open>Scala.Null\<close> in ML. |
229 exception \<^ML>\<open>Scala.Null\<close> in ML. The execution of \<open>@{scala}\<close> works via a |
|
230 Scala future on a bounded thread farm, while \<open>@{scala_thread}\<close> always forks |
|
231 a separate Java thread. |
228 |
232 |
229 The standard approach of representing datatypes via strings works via XML in |
233 The standard approach of representing datatypes via strings works via XML in |
230 YXML transfer syntax. See Isabelle/ML operations and modules @{ML |
234 YXML transfer syntax. See Isabelle/ML operations and modules @{ML |
231 YXML.string_of_body}, @{ML YXML.parse_body}, @{ML_structure XML.Encode}, |
235 YXML.string_of_body}, @{ML YXML.parse_body}, @{ML_structure XML.Encode}, |
232 @{ML_structure XML.Decode}; similarly for Isabelle/Scala. Isabelle symbols |
236 @{ML_structure XML.Decode}; similarly for Isabelle/Scala. Isabelle symbols |