जोकैमल

From alpha
Jump to navigation Jump to search
JoCaml
डेवलपर(ओं)INRIA
Stable release
4.01 / March 2014
ऑपरेटिंग सिस्टमCross-platform
प्रकारProgramming language
लाइसेंसLGPL
वेबसाइटhttp://jocaml.inria.fr/

जोकैमल[1][2] OCaml से प्राप्त एक प्रायोगिक कार्यात्मक प्रोग्रामिंग भाषा है। यह लचीला, प्रकार की सुरक्षा | टाइप-चेक समवर्ती कंप्यूटिंग और वितरित कंप्यूटिंग प्रोग्रामिंग को सक्षम करने के लिए जोड़-गणना के आदिम को एकीकृत करता है। JoCaml का वर्तमान संस्करण अब अनुरक्षित JoCaml का पुन: कार्यान्वयन है[3] Fabrice Le Fessant द्वारा बनाया गया, मूल की तुलना में एक संशोधित सिंटैक्स और बेहतर OCaml संगतता की विशेषता है।

JoCaml का उपयोग टीम Camls 'R Us द्वारा एक वितरित किरण अनुरेखक को लागू करने के लिए किया गया था,[4] ICFP 2000 प्रोग्रामिंग प्रतियोगिता में दूसरा स्थान अर्जित किया।

यह नाम जो कैमल के संदर्भ में है, ऊंट (सिगरेट) | कैमल-ब्रांड सिगरेट के विज्ञापनों में इस्तेमाल होने वाला एक कार्टून ऊंट

उदाहरण

type coins = Nickel | Dime
and drinks = Coffee | Tea
and buttons = BCoffee | BTea | BCancel;;
 
(* def defines a Join-pattern alternatives set clause
   * '&' in the left side of '=' means join (channel synchronism)
   * '&' in the right hand side is parallel processing
   * synchronous_reply :== "reply" [x] "to" channel_name
   * synchronous channels have function-like types (`a -> `b)
   * while asynchronous ones have type `a Join.chan
   * only the last statement in a pattern rhs expression can be an asynchronous message
   * 0 in an asynchronous message position means STOP ("no sent message" in CSP terminology).
   *)
 
def put(s) = print_endline s ; 0 (* STOP *) 
  ;; (* put: string Join.chan *)
 
def give(d) = match d with
                 Coffee -> put("Coffee")
                 | Tea -> put("Tea")
              ;; (* give: drink Join.chan *)
 
def refund(v) = let s = Printf.sprintf "Refund %d" v in put(s) 
    ;; (* refund: int Join.chan *)
 
let new_vending give refund =
  let vend (cost:int) (credit:int) = if credit >= cost
                      then (true, credit - cost)
                      else (false, credit)
  in
  def coin(Nickel) & value(v) = value(v+5) & reply to coin
  or coin(Dime) & value(v) = value(v+10) & reply to coin
 
  or button(BCoffee) & value(v) = 
     let should_give, remainder = vend 10 v in
     (if should_give then give(Coffee) else 0 (* STOP *)) 
             & value(remainder) & reply to button
 
  or button(BTea) & value(v) = 
     let should_give, remainder = vend 5 v in
     (if should_give then give(Tea) else 0 (* STOP *)) 
             & value(remainder) & reply to button
 
  or button(BCancel) & value(v) = refund( v) & value(0) & reply to button
  in spawn value(0) ;
  coin, button  (* coin, button: int -> unit *)
  ;; (* new_vending: drink Join.chan -> int Join.chan -> (int->unit)*(int->unit) *)
 
let ccoin, cbutton = new_vending give refund in
  ccoin(Nickel); ccoin(Nickel); ccoin(Dime); 
  Unix.sleep(1); cbutton(BCoffee); 
  Unix.sleep(1); cbutton(BTea); 
  Unix.sleep(1); cbutton(BCancel);
  Unix.sleep(1) (* let the last message show up *)
  ;;

कार्यान्वयन

$ jocamlc example.ml -o test
$ ./test
Coffee
Tea
Refund 5


यह भी देखें

  • ज्वाइन-कैलकुलस

संदर्भ

  1. Qin Ma and Luc Maranget (2004). "ज्वाइन-पैटर्न में पैटर्न-मिलान का संकलन". Proc. Of the 15th International Conference on Concurrency Theory. LNCS. Springer-Verlag. 3170.
  2. Ma, Qin; Maranget, Luc (2008). "Algebraic Pattern Matching in Join Calculus". Logical Methods in Computer Science. 4 (1). arXiv:0802.4018. Bibcode:2008arXiv0802.4018M. doi:10.2168/LMCS-4(1:7)2008. S2CID 15873901.
  3. Conchon, S.; Le Fessant, F. (1999). "Jocaml: Mobile agents for Objective-Caml". कार्यवाही। एजेंट सिस्टम एप्लीकेशन और मोबाइल एजेंट पर पहला और तीसरा अंतर्राष्ट्रीय संगोष्ठी. pp. 22–29. doi:10.1109/ASAMA.1999.805390. ISBN 0-7695-0342-X. S2CID 14355301.
  4. Louis Mandel; Luc Maranget. "ओकैमल में प्रोग्रामिंग". Inria research report 6261.


बाहरी संबंध