src/HOL/Imperative_HOL/Ref.thy
changeset 52435 6646bb548c6b
parent 51090 bee2678a3b61
child 54703 499f92dc6e45
equal deleted inserted replaced
52434:cbb94074682b 52435:6646bb548c6b
   273   by (simp add: ref'_def)
   273   by (simp add: ref'_def)
   274 
   274 
   275 
   275 
   276 text {* SML / Eval *}
   276 text {* SML / Eval *}
   277 
   277 
   278 code_type ref (SML "_/ ref")
   278 code_printing type_constructor ref \<rightharpoonup> (SML) "_/ ref"
   279 code_type ref (Eval "_/ Unsynchronized.ref")
   279 code_printing type_constructor ref \<rightharpoonup> (Eval) "_/ Unsynchronized.ref"
   280 code_const Ref (SML "raise/ (Fail/ \"bare Ref\")")
   280 code_printing constant Ref \<rightharpoonup> (SML) "raise/ (Fail/ \"bare Ref\")"
   281 code_const ref' (SML "(fn/ ()/ =>/ ref/ _)")
   281 code_printing constant ref' \<rightharpoonup> (SML) "(fn/ ()/ =>/ ref/ _)"
   282 code_const ref' (Eval "(fn/ ()/ =>/ Unsynchronized.ref/ _)")
   282 code_printing constant ref' \<rightharpoonup> (Eval) "(fn/ ()/ =>/ Unsynchronized.ref/ _)"
   283 code_const Ref.lookup (SML "(fn/ ()/ =>/ !/ _)")
   283 code_printing constant Ref.lookup \<rightharpoonup> (SML) "(fn/ ()/ =>/ !/ _)"
   284 code_const Ref.update (SML "(fn/ ()/ =>/ _/ :=/ _)")
   284 code_printing constant Ref.update \<rightharpoonup> (SML) "(fn/ ()/ =>/ _/ :=/ _)"
   285 code_const "HOL.equal :: 'a ref \<Rightarrow> 'a ref \<Rightarrow> bool" (SML infixl 6 "=")
   285 code_printing constant "HOL.equal :: 'a ref \<Rightarrow> 'a ref \<Rightarrow> bool" \<rightharpoonup> (SML) infixl 6 "="
   286 
   286 
   287 code_reserved Eval Unsynchronized
   287 code_reserved Eval Unsynchronized
   288 
   288 
   289 
   289 
   290 text {* OCaml *}
   290 text {* OCaml *}
   291 
   291 
   292 code_type ref (OCaml "_/ ref")
   292 code_printing type_constructor ref \<rightharpoonup> (OCaml) "_/ ref"
   293 code_const Ref (OCaml "failwith/ \"bare Ref\"")
   293 code_printing constant Ref \<rightharpoonup> (OCaml) "failwith/ \"bare Ref\""
   294 code_const ref' (OCaml "(fun/ ()/ ->/ ref/ _)")
   294 code_printing constant ref' \<rightharpoonup> (OCaml) "(fun/ ()/ ->/ ref/ _)"
   295 code_const Ref.lookup (OCaml "(fun/ ()/ ->/ !/ _)")
   295 code_printing constant Ref.lookup \<rightharpoonup> (OCaml) "(fun/ ()/ ->/ !/ _)"
   296 code_const Ref.update (OCaml "(fun/ ()/ ->/ _/ :=/ _)")
   296 code_printing constant Ref.update \<rightharpoonup> (OCaml) "(fun/ ()/ ->/ _/ :=/ _)"
   297 code_const "HOL.equal :: 'a ref \<Rightarrow> 'a ref \<Rightarrow> bool" (OCaml infixl 4 "=")
   297 code_printing constant "HOL.equal :: 'a ref \<Rightarrow> 'a ref \<Rightarrow> bool" \<rightharpoonup> (OCaml) infixl 4 "="
   298 
   298 
   299 code_reserved OCaml ref
   299 code_reserved OCaml ref
   300 
   300 
   301 
   301 
   302 text {* Haskell *}
   302 text {* Haskell *}
   303 
   303 
   304 code_type ref (Haskell "Heap.STRef/ Heap.RealWorld/ _")
   304 code_printing type_constructor ref \<rightharpoonup> (Haskell) "Heap.STRef/ Heap.RealWorld/ _"
   305 code_const Ref (Haskell "error/ \"bare Ref\"")
   305 code_printing constant Ref \<rightharpoonup> (Haskell) "error/ \"bare Ref\""
   306 code_const ref' (Haskell "Heap.newSTRef")
   306 code_printing constant ref' \<rightharpoonup> (Haskell) "Heap.newSTRef"
   307 code_const Ref.lookup (Haskell "Heap.readSTRef")
   307 code_printing constant Ref.lookup \<rightharpoonup> (Haskell) "Heap.readSTRef"
   308 code_const Ref.update (Haskell "Heap.writeSTRef")
   308 code_printing constant Ref.update \<rightharpoonup> (Haskell) "Heap.writeSTRef"
   309 code_const "HOL.equal :: 'a ref \<Rightarrow> 'a ref \<Rightarrow> bool" (Haskell infix 4 "==")
   309 code_printing constant "HOL.equal :: 'a ref \<Rightarrow> 'a ref \<Rightarrow> bool" \<rightharpoonup> (Haskell) infix 4 "=="
   310 code_instance ref :: HOL.equal (Haskell -)
   310 code_printing class_instance ref :: HOL.equal \<rightharpoonup> (Haskell) -
   311 
   311 
   312 
   312 
   313 text {* Scala *}
   313 text {* Scala *}
   314 
   314 
   315 code_type ref (Scala "!Ref[_]")
   315 code_printing type_constructor ref \<rightharpoonup> (Scala) "!Ref[_]"
   316 code_const Ref (Scala "!sys.error(\"bare Ref\")")
   316 code_printing constant Ref \<rightharpoonup> (Scala) "!sys.error(\"bare Ref\")"
   317 code_const ref' (Scala "('_: Unit)/ =>/ Ref((_))")
   317 code_printing constant ref' \<rightharpoonup> (Scala) "('_: Unit)/ =>/ Ref((_))"
   318 code_const Ref.lookup (Scala "('_: Unit)/ =>/ Ref.lookup((_))")
   318 code_printing constant Ref.lookup \<rightharpoonup> (Scala) "('_: Unit)/ =>/ Ref.lookup((_))"
   319 code_const Ref.update (Scala "('_: Unit)/ =>/ Ref.update((_), (_))")
   319 code_printing constant Ref.update \<rightharpoonup> (Scala) "('_: Unit)/ =>/ Ref.update((_), (_))"
   320 code_const "HOL.equal :: 'a ref \<Rightarrow> 'a ref \<Rightarrow> bool" (Scala infixl 5 "==")
   320 code_printing constant "HOL.equal :: 'a ref \<Rightarrow> 'a ref \<Rightarrow> bool" \<rightharpoonup> (Scala) infixl 5 "=="
   321 
   321 
   322 end
   322 end
       
   323