GNU Free Documentation License . .

Oz ( )

: ,
Oz
:

, , , -, , -,

:

:

1991

():

Gert Smolka & his students

:

1.4.0 (July 3 2008)

:

Mozart

:

:

Alice

:

www.mozart-oz.org

Oz  , , , .

[]

Oz 1991 Gert Smolka . 1996 Seif Haridi Peter Van Roy (Swedish Institute of Computer Science), Concepts, Techniques, and Models of Computer Programming[1]. 1999 2005 - (Mozart Consortium), : (Saarland University), (Swedish Institute of Computer Science) .

Oz  Mozart IDE Emacs, , , .

Mozart 2005 (Mozart Board) . Mozart Consortium () , Unix, FreeBSD, Linux, Microsoft Windows Mac OS X.

[]

Oz , , ( , «» ), , -, , . , Oz ,   .

, , . , , . Oz (computation spaces), . , .

[]

[]

, .. .

:

  • ( )
  • ( ): circle(x:0 y:1 radius:3 color:blue style:dots)
  • ( ):
'|'(2 '|'(4 '|'(6 '|'(8 nil))))
2|(4|(6|(8|nil))) %  
2|4|6|8|nil %    
[2 4 6 8] %        

(first class), .

[]

, :

fun {Fact N} % 
   if N =< 0 then 1 else N*{Fact N-1} end
end

fun {Comb N K} %  
   {Fact N} div ({Fact K} * {Fact N-K}) %        
end

fun {SumList List} %   
   case List of nil then 0
   [] H|T then H+{SumList T} %     
   end
end

[]

, , :

thread 
   Z = X+Y     %    ,   X  Y   
   {Browse Z}  %   Z
end
thread X = 40 end
thread Y = 2 end

, , :

X = 1
X = 2 % error

, :

fun {Ints N Max}
   if N == Max then nil
   else 
      {Delay 1000}
      N|{Ints N+1 Max}
   end
end

fun {Sum S Stream}
   case Stream of nil then S
   [] H|T then S|{Sum H+S T} end
end

local X Y in
   thread X = {Ints 0 1000} end
   thread Y = {Sum 0 X} end
   {Browse Y}
end

, , , , . : , 100 000 [2].

[] Oz

[]

. , :

fun {Sieve Xs}
   case Xs of nil then nil
   [] X|Xr then Ys in
      thread Ys = {Filter Xr fun {$ Y} Y mod X \= 0 end} end
      X|{Sieve Ys}
   end
end

[]

, Oz , .. :

fun lazy {Fact N}
   if N =< 0 then 1 else N*{Fact N-1} end
end
local X Y in
  X = {Fact 100} 
  Y = X + 1 %    X,      
end

[]

:

declare
local Stream Port in
   Port = {NewPort Stream}
   {Send Port 1} % Stream is now 1|_ ('_' indicates an unbound and unnamed variable)
   {Send Port 2} % Stream is now 1|2|_ 
   ...
   {Send Port n} % Stream is now 1|2| .. |n|_
end 

:

fun {NewAgent Init Fun}
   Msg Out in
   thread {FoldL Msg Fun Init Out} end
   {NewPort Msg}
end

[]

- ; Cells, :

local A X in
   A = {NewCell 0}
   A := 1  % changes the value of A to 1
   X = @A  % @ is used to access the value of A
end

- :

class Counter
   attr val
   meth init(Value)
      val:=Value
   end
   meth browse
      {Browse @val}
   end
   meth inc(Value)
      val :=@val+Value
   end
end

local C in
   C = {New Counter init(0)}
   {C inc(6)}
   {C browse}
end

[] Oz,

:

 
+
 ---

 =0       .

:

local Fut Res in
proc {Fut C} 
 F#U#T#B#O#L#G#R#A = C 
in 
 C ::: 0#9 
 {FD.distinct C} 
 F \=: 0 
 B \=: 0 
 100 * F + 10* U + T + 100*B + 10*O + L =: 100*G + 10*R + A 
 {FD.distribute ff C} 
end 
{SearchAll Fut Res} 
{Browse Res} 
end 

.

[] .

[]

[]