Concurrent ML

Concurrent ML

Concurrent ML (CML) is a concurrent extension of the Standard ML programming language.

Sample Code

Here is sample code to print "hello, world" to the console. It spawns a thread which creates a channel for strings. This thread then spawns another thread which prints the first string that is received on the channel. The former thread then sends the "hello, world\n" string on the channel. It uses SML/NJ and CML (note that the heap name will be different on non linux-x86 platforms; you may need to change the line with "cml_test.x86-linux" to something different):

cml_test.cm:

   Library
       structure Hello
   is
       $cml/basis.cm
       $cml/cml.cm
       cml_test.sml

cml_test.sml:

   structure Hello =
   struct
       open CML
           
       fun hello () =
           let val c : string chan = channel ()
           in
               spawn (fn () => TextIO.print (recv c));
               send (c, "hello, world\n");
               exit ()
           end
           
       fun main (name, argv) =
           RunCML.doit (fn () => ignore (spawn hello), NONE)
   end

Running:

   $ ml-build cml_test.cm Hello.main
   Standard ML of New Jersey v110.60 [built: Mon Nov 27 14:19:21 2006]
   [scanning cml_test.cm]
   [library $cml/basis.cm is stable]
   [library $cml/cml.cm is stable]
   [parsing (cml_test.cm):cml_test.sml]
   [creating directory .cm/SKEL]
   [library $cml/cml-internal.cm is stable]
   [library $cml/core-cml.cm is stable]
   [library $SMLNJ-BASIS/basis.cm is stable]
   [compiling (cml_test.cm):cml_test.sml]
   [creating directory .cm/GUID]
   [creating directory .cm/x86-unix]
   [code: 2170, data: 42, env: 2561 bytes]
   [scanning 18518-export.cm]
   [scanning (18518-export.cm):cml_test.cm]
   [parsing (18518-export.cm):18518-export.sml]
   [compiling (18518-export.cm):18518-export.sml]
   [code: 309, data: 37, env: 42 bytes]
   $ heap2exec cml_test.x86-linux cml_test
   $ ./cml_test
   hello, world

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • concurrent — concurrent, ente [ kɔ̃kyrɑ̃, ɑ̃t ] adj. et n. • 1119; lat. concurrens, de concurrere « accourir ensemble » 1 ♦ Astron. Jours concurrents, ou ellipt les concurrents : jours qui s ajoutent aux cinquante deux semaines de l année pour faire concorder …   Encyclopédie Universelle

  • concurrent — con·cur·rent /kən kər ənt/ adj 1: occurring, arising, or operating at the same time often in relationship, conjunction, association, or cooperation the power of taxation in the general and state governments is acknowledged to be concurrent… …   Law dictionary

  • concurrent — concurrent, ente (kon ku rran, ran t ) s. m. et f. 1°   Celui, celle qui prétend à une chose en même temps qu un autre. •   Il s est débarrassé de la foule importune, Du turbulent espoir de tant de concurrents, CORN. Pulch. II, 1. •   La reine… …   Dictionnaire de la Langue Française d'Émile Littré

  • Concurrent — Con*cur rent, a. [F. concurrent, L. concurrens, p. pr. of concurrere.] 1. Acting in conjunction; agreeing in the same act or opinion; contributing to the same event or effect; co[ o]perating. [1913 Webster] I join with these laws the personal… …   The Collaborative International Dictionary of English

  • concurrent — UK US /kənˈkʌrənt/ adjective ► happening or existing at the same time as something else: »Delivery of the goods and payment of the price are concurrent conditions, and must therefore occur at the same time. concurrent with sth »Competitions for… …   Financial and business terms

  • Concurrent ML — Auteur John Reppy Dernière version 110.71 (16 septembre 2009) [ …   Wikipédia en Français

  • concurrent — late 14c., from O.Fr. concurrent or directly from L. concurrentem (nom. concurrens), prp. of concurrere (see CONCUR (Cf. concur)). Related: Concurrency; concurrently. Concurrent jurisdiction is recorded from 1767 …   Etymology dictionary

  • concurrent — [kən kʉr′ənt] adj. [ME < L concurrens: prp. of concurrere,CONCUR] 1. occurring at the same time; existing together 2. meeting in or going toward the same point; converging 3. acting together; cooperating 4. in agreement; harmonious 5.… …   English World dictionary

  • Concurrent — Con*cur rent, n. 1. One who, or that which, concurs; a joint or contributory cause. [1913 Webster] To all affairs of importance there are three necessary concurrents . . . time, industry, and faculties. Dr. H. More. [1913 Webster] 2. One pursuing …   The Collaborative International Dictionary of English

  • concurrent — [adj1] simultaneous circumstantial, coeval, coexisting, coincident, concerted, concomitant, contemporaneous, incidental, in sync, parallel, synchronal, synchronous; concept 799 concurrent [adj2] agreeing, converging allied, at one, centrolineal,… …   New thesaurus

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”