Multi-Thread Icon

Threads

Loading and Activating Programs

procedure main(args)
   every write(!args)
   return
end
mticont example

translates example.icn and produces an icode file named example

procedure main()
   prog := load("example", ["Hi", "mom"])
   @prog
   write("Good-bye")
end

then

mticont mttest -x

translates and executes mttest.icn

icont example -x Hi mom

the output produced is

Hi
mom
Good-bye

before itself terminating, which ends the execution of MT Icon

Communication Among Programs

x @ C

which activates C and transmits x to it (@C is just an abbreviation for &null @ C)

procedure main()

   prog := load("textlist")
   @prog                                     # wake up!
   while read() @ prog
   lines := cofail(prog)
          ...
procedure main()
   L := [ ]
   while put(L, @&source)
   L @ &source
end

Data Spaces

MT Icon Functions

globalnames(C)

generates the names of the global identifiers in the thread that contains C

variable(s, C)
every ident := globalnames(prog) do
   write(
      ident,
      " : ",
      image(variable(ident, prog))
      )
variable("write", prog) := 1
variable("writes", prog) := 1

which has the effect of turning off output in prog

write(keyword("subject", prog))
writes the value of &subject in prog
keyword("subject", prog) := text

assigns text to &subject in prog

display(i, f, C)
name(x, C)
proc(x, i, C)
localnames(C)
paramnames(C)
staticnames(C)

Input and Output

load(s, L, f1, f2, f3)

The Relationship Among Loaded Programs

procedure main()
   @load("b")
         ...

and b.icn is

procedure main()
   load("c")
   load("d")
          ...

then the load tree after load("d") in b can be depicted as:

parent(C)

produces the parent of C but fails if C is the root of the load tree

procedure root()
   prog := &main
   while prog := parent(prog)
   return prog
end

Code Sharing

global gcd
          ...
library := root()
gcd := proc("gcd", , library) |
   stop("*** cannot get procedure")
          ...