:




      : 03.05.2002

       : mailto:dgaev@mail.ru


     

                  
      (   
2002 .).              
        " " .
      ,      
  -     .     , 
            
 .

     ,          
- ,      
-   - (, C++  Java).




     

     o 

     o   

     o      

     o ,   

     o   

     o   

     o   

     o    

     o   

     o  

     o   . 

     o   

     o 




     :    



             ,  .  
,  -- .
  ,  -- .   ,  -- ...

. , . 
"   "

     

            --              ,       
-     .        
      :  C    C++,    (  
-  ,        Delphi)    Java.  
,                 
Algol-68,  Simula,  BCPL, CLU,  Eiffel        
.

               (   -)   
,     C++  (  ) Java.
   "" - ,   SmallTalk
  Actor:       "", " " 
        .
                
         .

      --    .   ,    
           ,      
       .
         ,    
 (),     .

         "  ", ..    
         ,   ,  ,
,    ... ,   
       (   ,
,    ).

         ,    
    ,      .
    :

     --       .            
,     ,    C++
 ,      ,  ,
,  Java.         
    . ,      
   ,       ,
       .

     --         
      .    -
         , 
  ()   , ..   
              .  
       ,     
    .       
,     ,  ,    ,
  ..  ,   ,    
 ,    .

     --               
.  ,             
,      ,         .
   ,  ,      
  static     strict,          
      .    
              
.

     --  .           ,      
  "" . ,    
        ,      
           ,   
           ..  
    ,       ,  
  ,              
.

     --     . ,  
      ,     
,  Java    C++.  ,       
   "",          .    
   ,       -
        .  ,
              
:            . 
                 
.          let      
 ""  (,    ).

     --     --        .
            -
(   ).         
            32-  ,  
         .

       

           -   
        .      :  ,
     ,   , ,   
.         
  (,               ),
  .

       ,    ,    
.    :

         ()    ,     
 !';

           !'    .

      ,        ,  
                               
("()","[]","{}","<>"  -   ),    
  .  :

     !!  
!    ... !
!{     }!

      --   ,     (
 ) : , ,   , , ,
,   .     
 ,    C:     , 
   ,    .    127
      ;       
.    ,        
.     :

     abstract, alloc, assert
bool, break
case, char, class, conceal, const, constructor, continue
destructor, do, double
else, enum, export
false, float, for
goto
if, import, inline, instate, int, interface
keyword
label, let, limited, long, loop
mediator
native, nil
opdef
package, pragma, private, protected
qual, quad
realloc, return
shared, short, static, strict, switch
tiny, this, true, type
u_int, u_long, u_short, u_tiny, unless, until
virtual, void
w_char, with, while

       ,        
,          .       
 ,   .. ,      ..
  -- ,     (alpha  `alpha`  --
     ).

     !!  :
x;
ABACUS:
file_12;
ActiveApplet;
` `

               
.        
  .         :  $o'
   , $h'  ( $x') --  ,
$b'  --    .         , 
   (.  ): 't' ( u_tiny), 's' ( u_short),
'i',  ( u_int,   ),  'l'  ( u_long).     
    C/C++,        : 'f'
( float,   ),  'd'  ( double), 'q' (  quad).  
  ( char)    .   (
char  [],    )    .    
C/C++,             (,  
 )       (  
,  ..          
).    (    ):

     37t; !! 37 (u_tiny)
     37s; !! 37 (u_short)
     $b100101; !! 37 (u_int)
     $o45; !!  ,   
     $x25; !!  ,   
     3.14159; !! 3.14159 (float)
     3.14159d; !! 3.14159 (double)
     true; !!  (bool)
     false; !!  (bool)
     '@'; !!  @' (char)
     " "; !!  (char [])
     " --    ,
        
      " !!    (char [])

          

                 
,          "",  
    .          ,   ,
   .      ,     
   "" .    -- 
  ,   (tiny, short, int, long)   
 (u_tiny, u_short, u_int, u_long). ""    
           :    tiny
  8  , short  --  16, int  -- 32  long --
64.                   ,  
    .     
  (    IEEE-754): float -- 
     ,   double   --            quad
(   ,           
  double).        :
 char  8-     ASCII/ISO,    w_char --
16-  Unicode.  ()  bool  
  :  (true)   (false).   
 void (),      ,  ,
  -,   - .

                ()  
.             (,  
, C-):

     !! I, J, K --   
u_int I = 1, J = 2, K = 3;
!! X, Y, Z --    
float X, Y, Z = 0.001;
!! DONE --  
bool DONE = false

               ,          
      (      ).  
      ,    
  ().

           ,         --
,        . 
        const.  ,     
   :

     !! space --  
char const space =  ;
!! factor --  
float const factor = 2 * PI * PI;
!! median --  
int const median = (low + high) // 2

         ,       
,           , 
   .  ,   
 :       ,    ,
        ,   (  )  
 ( ). ,        
    (static), ..   , 
   :

     u_int i, j, static counter = 0

     ,     static --    
(  , counter),     ,    C.

             .  
           ,          
   C.        . , 
     C,              ('/')  
  ('//')    (        
  '-/').      C-  
     ('<<'  '>>'),   
    ('<.<'  '>.>'),    
   ('>.<').  (            
"  ":        u_tiny     
     4 ,  u_short -    8    ..)
,     C-   
('++')   ('-- ')     .

             bool.    
              ('--')      
('<>'),                
  ('<',  '<=',  '>',  '>=').     ,  
        .   (       
,              
,      false <  true).  ,
       "" ('?>')
 "" ('?<'),  ,  ,     
 .

        -   ""  ('&'), ""
('|')    " "  ('~')    ,    
 (     ).    
       ""  ('~').          bool  
-  ""  ""  ('&&'  '||'), , 
    C,            .    
C-     : X ?  Y : Z     "  X
(   bool),  Y,  Z". ,   ('=')
      C            (
     ,       ).  
 ,      , 
 '+=', '-=', '*=', '/='  ..

          C    Java,         ','
().       : 
      ,       
:

     !! " ",  
({ STMT_LIST } EXPR);

!! " ",  
(EXPR { STMT_LIST })

                    EXPR.
,         STMT_LIST --  
EXPR (  )     ( ).  , 
         ,        
  .

                  ,  
,          
. ,         ('<:')  
(':>'),         ,               
    ,                
   (,         -      
).

                  C. ,
     , ..    
 ,         .    
-   (  ,     ). 
 ,   ,   .

             ,
       ,   C. 
   ,           .  ,
        (tinyshortintlong),  ,     (floatdoublequad)       (charw_char),    
        .     
:  ,        
        (  ).      
          :    
       .

         ,      
  ,   :

     :TYPE EXPR !!   EXPR   TYPE

                      
:             
 ,    --      ,
     false  true    0  -1. 
  ,             
 ,   ,    C,  .

      ( )

       --        ,  
        ()  
 --       .    Java
     ,          . 
         (  ,   
.),     .

        :

     !! intvec --   LENGTH 
      int [LENGTH] intvec;
!! text --  , (HEIGHT ) * (WIDTH )
char [WIDTH][HEIGHT] text

        ,     -- :
    [SIZE]          ()
.  ,         TYPE
  TYPE [SIZE] (  SIZE    TYPE).    
    ,     -      .
 ,  "  "       --   
  ,   ,   .    
 ,   n-   (   n  
 ,     ).  ,  
     (..    
       ).

     ,            --    
.               
  ,            
            --   (
       "" ).    C,
()     ,  ,  
  :

     int [10] aa, bb !! aa --   10 , bb -- 

     ,               
.     (      
)     "     "  ().    ,  
,    :

     int [10] { aa, bb } !! aa  bb --   10 

         :

     int i, [10] { v, [20] { vv, [30] vvv } };
!!     :
int i, [10] v, [10][20] vv, [10][20][30] vvv

                 u_int. 
     --  ,  , 
        .       
      .  ,    
,     ,           (
      ,          "
").           
  :  ,       ,      
  .        ,  ..  
   .

          .  ,      
      ,   
     '#'.  ,  :

     intvec#; !!   LENGTH (u_int)
text#; !!   HEIGHT (u_int)
vvv# !!  30 (u_int)

           .   
            
.  ,    C,     :

     !!    intvec (int)
intvec [0];
!!    intvec (int)
intvec [LENGTH - 1];
!! ""   text (char [WIDTH])
text [0];
!! ""   text (char [WIDTH])
text [HEIGHT - 1];
!! " "   text (char)
text [0][0];
!! " "   text (char)
text [HEIGHT - 1][WIDTH - 1]

               ,  
    .    A [I] 
  I <  A#,      
         (ArraySizeException).  
,           ,
                 .
(      C    "    "  
  "   ":   , 
     ,   
   (,  ,   )  -- 
).

            :     
    ,     ,     
.      ,    ,           ,
                 ().
       -- A [FROM..TO]  --   
  A   ()        FROM   (  )
     TO (..  : A [FROM..TO]# -- TO --
FROM). ,     (  
FROM <= TO && TO <= A#,      
ArraySizeException).  ,     ,    
.

     V [0 .. N] !! :  N   V
V [V#-N .. V#] !! :  N   V

           ,       
    :        ,    
.     1  --      1,        .
 ,          
     , ..      
.  ,  ,             
    ,     L-
(..   ,       
 ..).

         ,    
 "  ".         
  :

     text [0]# !!  WIDTH
text []# !!   

         ,      --   ,  
      , ..     
      text,              
.  ,      []  --   ..  
,  ,   .    
,  ,    ,   .

      ,     ,  :

     float [25] { VA, VB };
VA = VB !!      VA   VB

          ,        
  (..    ,      , 
     ).   ,       
  (  ,   ). ,
       ,     
  . ,     :

     char [SIZE1] str1, [SIZE2] str2;
str1 = str2

            SIZE1  -- SIZE2,
,        ,            
ArraySizeException.

        ,       .    
   (    )   ""    
  .            
 :           --
   ""      .   
  ,      ,  
""      :

     !{  str1  HEIGHT   text
  ( ,  text []# -- str1#,
     .. WIDTH -- SIZE1) }!
text = str1

                .
          ,        
                    
.                   
:    ('=#')    ('=#@') (  
  ):

     A [10..19] =# A [15..24]; !!  
A [10..19] =#@ A [15..24] !!  

                A.  
               
,  ..               ""  
.   ,        ,
       .     .
,     ""          
,     ""  
  (  )  .

          ,    (  
--   )  . , ,     
,      . ,  ,
      -- .

     int [5] List1 = { 1, 2, 3, 4, 5 };
int [5] List2 = { 1, List1[2]*3, List1[0]*List1[4] + 2, 4, List1# }

          ,  --  ,
      .           
   .                  
    .   ,    
 :

     int [3][5] Matrix = {
!!  #0:  
{ 100, 200, 300 },
!!  #1:   List1
List1 [0..3],
!!  #2:  
{ List1[0]*List2[2], List1[1]*List2[1], List1[2]*List2[0] },
!!  #3:   List2
List2 [2..5],
!!  #4:  100  3 
100
}

           --    ..  
,      .    
                ,  ..
  , ,   , :

     List1 = { 10, 20, 30, 40, 50 } !! !

              ,     
.  ,     , ,   
,          .  ,    
        .   
   /:    ,
       ;   
  :

     str1 -- str2; !! ,  str1# -- str2#
              !!  str1 [I] -- str2 [I]   I
str1 <> str2 !!   

           (,  
),          .   
     ("")
   .        ""  
""  :

     str1 < str2; !! ,    N, 
              !!   1)   str1 [0..N] -- str2 [0..N]
              !!   2)   str1#
-- N && str2# > N
              !!          
              !!      str1 [N]
< str2 [N]

     str1 > str2 !! ,    N, 
              !!   1)   str1 [0..N] -- str2 [0..N]
                 !!   2)   str1# > N &&
str2# -- N
                 !!          
              !!      str1 [N]
> str2 [N]

      :  str1  []  str2,   
    str1  []  
  str2,        str1   str2,  
str1   str2 [...   str2   str1,   
str2   str1].

                  
 .          ,
  ,             ""
 .     :

     str1 --   !! ,    str1 -- 
str1  <>    !!  ,         str1  

str1 -- text !! ,  str1# -- text []#
              !!    text   str1
str1 <> text !! ,  str1# <> text []#
              !!      text   str1

        , ,  ,     
,            .     
      ().       
      ('--',  '<>',   '<',   '>'  ...)  
   ('--#', '<>#', '<#', '>#'
...)      ('--#@',   '<>#@',  '<#@',  '>#@'   ...)
.         ,
  ,          
     .     -- 
            bool,      u_int  --      ,
    /    ,   
   (    ,    --  
),     . , 
  :

     !!   :
VAL -- A --# B; !! , :
                   !! A [0..VAL] -- B [0..VAL]
                   !!   
                   !! A [VAL] <> B [VAL]
                   !! (  ).

     !!   :
VAL -- A --#@ B; !! , :
                   !! A [A#-VAL..A#] -- B [B#-VAL..B#]
                   !!   
                   !! A [A#-VAL-1] <> B [B#-VAL-1]
                   !! (  ).

             ,         
.  ,         
    :

     !!      str1:
if (first_count = str1 <>#  ) -- str1#
     { !(    ... )! }
else { !( str1 [first_count] --   )! }

     !!      str1:
if (last_count = str1 <>#@  ) -- str1#
     { !(    ... )! }
else { !( str1 [str# - last_count - 1] --   )! }

      ,        
     .       ,    
            ,
    .   ,       
  ,         
,      - .

        

           ,   ,      
  , ,          
.             .
   Java,      ,      
, ..           .  
    :     C  ,  
    . ,    C,  
           ,       
.

               
'^'. :

     int ^ip; !! ip -   
int ^^ipp !! ipp -     

            :

     int ^{ ip, ^ ipp } !!  ,   

       '^'        const,  limited  
strict,       .    
     -- nil,      
.

            :   .
,  L-              
   ( '@'):

     int a; double b;
a@; !!    a (int ^)
b@ !!    b (float ^)

       --  ( '^')  --  
     (),       (
  -- L-). ,      
nil     (NilDerefException).

     ip^; !!  ip (int)
ipp^; !!  ipp (int ^)
ipp^^ !!  ipp  (int)

             .
          .

       ,      ,    
    :       
 ,       nil,  
     .  ,  ,
     .

     ,             
.      C,      ,  
         (  qual,
              
 ,    ).

           ,            
  .           
       ,     
,           ""
.

     int iv1, ^ip1;
{
int iv2, ^ip2;
ip1 = iv1@; !! 
ip2 = iv2@; !! 
ip1 = iv2@; !! !
ip2 = iv1@; !! 
ip1 = ip2; !! !
ip2 = ip1 !! 
}

            ,       
  . ,    (const),
           .    
        ,      
  --   .    
   ,    .   ,
   ,    .

     ,            
   .  ,    C,     
  , ,         
.         
 , ,     /. 
     /      
    (   , 
     ).

                    
,          .    
         --  ,
             
    .  :

     !!     ...
int ^ip, [4] ^ivp;
!!   ,      ...
int alloc (ip) = 5, [4] alloc (ivp) = { 0, 10, 20, 30 };
!! ...     :
ip^; !! 5 (int)
ivp^#; !! 4 (u_int)
ivp^ [3]; !! 30 (int)

         .    
 C++   new,      :

     ip = new int;
ip^ = 5;
ivp = new int [4];
ivp^ = { 0, 10, 20, 30 }

        alloc  (PTR)    , ..
    ,     
  .      TYPE,    PTR
--   L-    TYPE  ^,    ""  
     .    -- 
  ,            .
  ,           ,    
   ,   .

                
  PTR. ,    alloc,        ,
      . 
         .
          ,    
.

         ,        
  limited.           
  ,       .       
""       :  
     (32   64)       
   .      
 ,         : 
               
          ,    
PointerDomainException.

            ,   
 .         ""
(   ),  .. -       
:

     float [] ^fv, [][] ^fvv

       fv   fvv --            
,   .      
   --            
.  fv     - , 
          fv,   
fv                 .     ,  
 ""      ,
  ""        32 
(      ). ,  ""
            
(,  )    .

                     
 -- .  -       
 :        
 ,         
.       ,
       .     
'^'   '@'.     :

     char ch1 = A', ch2 = B'; !!  
char ^pc = ch1@; !! pc:   ch1
pc^ = C'; !!  ch1 -- C'
char @rc = ch1; !! rc:   ch1
rc = D'; !!  ch1 -- D'

             C++,   
  .   C++  --    (
,      ),             
 (  ),    .   
      (       ..).
,    C++,   :   
 ,    (..      
 ),   ,        
 L-,   :

     rc@ = ch2@; !!  rc   ch2
rc = E'; !!  ch2 -- E'

                .  
   ,     " " --  
,     C++,        
  --     ,  ()
 .

        

             ,       
,               
().            ,
  ,     ( ).
           (
      ),        
  ,     .

                  
       ,      ('  <
> )':

     !! int_op -    
!!  (a, b),  int
int (int a, b) int_op;

!! f_func --      ,
!!  float
float (float [] ^farray; char ch1, ch2; bool flag) f_func;

         --        ,
      .     ,    
,    .   
,     int_op  f_func --    
( " ",         ++). , 
          , 
      :

     int (int a, b) op_add { return a + b }; !!  
int (int a, b) op_sub { return a -- b } !!  

          <>  { < >
}',       <>,       (
  )    .   ,
  op_add   op_sub       (
 return   " ",     ).  
,      --      ,  ..
     ,        ,    
   ,      (  
  ""      -- ,  , 
).    , ,    :

     !!      ...
int (int a, b) { op_mul { return a * b }, op_div { return a // b } }

                       
 . ,    ,   ,
    ,                (   
/).  :

     op_add (6, 5); !! 11
int_op = op_add; !!  int_op --  op_add
int_op (5, 4); !! 9
int_op -- op_add; !! true
int_op = op_mul; !!  int_op --  op_mul
int_op (10, 5); !!  50
int_op <> op_add; !! true
int_op -- op_mul !! true
op_sub = int_op !! ! (op_sub -- ,   )

       :          
-      /.  ,  
             ,  
       .  -,  , 
      . ,       
 nil (  ) ,   ,  
      . ,  ""
nil      (NilInvokeException).  
    ,          
    :   ,
    ,     .

        "  "    C  C++.  
   #'<>  --        ()  
<>.             ,
,            . 
 :

     float (float x, y) #power; !!   power

       power   ,    :

     float result = power (x, 0.5) !!    x

         ,      (
    ,    )     
 #'<>< >. :

     #power { return exp (y * log (x)) }

         ,        
      --    . 
,       power  
, ..        !
       :       
 ,         .  
  ,    ,            
,        ,          :     
.                  
 ,      :

     float (float x, y) power { return exp (y * log (x)) }

               ,    
 - ,     ( 
 )  .

                     
.    N- ,   
   .      ,
              .
               
, ..        
  :

     void (float x, y; bool p, q) z_func;

z_func (0.5, 1.5, true, true)
!! (.. x ← 0.5, y ← 1.5, p ← true, q ← true)

     ,         ,      
           <>
:'. ,  :

     z_func (p: false, q: true, x: 0.0, y: 1.0)
!! (x ← 0.0, y ← 1.0, p ← false, q ← true)

                 .  
    ,         
 (  ,     ). , 
     ,     
 (    ):

     z_func (3.14, , false, false, y: 8.9)
!! (x ← 3.14, y ← 8.9, p ← false, q ← false)

                 
,                ,    
  ( ) .    , 
    .   ,    ,
    ,        .
         ""      .
       C++,     
         ,   
       .           
.    ,      (   )  
   ,           
 ,    .   
   :

     !! ,      
void (int a = 5; int b = a; int c = a + b) x_func;
x_func (11, 12, 13); !!    
!! (a ← 11, b ← 12, c ← 13)
x_func (10, 20); !! a  b , c  
!! (a ← 10, b ← 20, c ← 30)
x_func (10); !! a , b  c  
!! (a ← 10, b ← 10, c ← 20)
x_func (); !!   
!! (a ← 5, b ← 5, c ← 10)

             -    
,        .      
 :

     !!  : C = A (*) B
void (u_int L, M, N; double [L][M] @A, [M][N] @B, [L][N] @C) MatrixProduct {
! ... ! }

           --    ,
..        ,       ,
   .      ,   
return.  ,  -  (   C, C++  Java)  
  (  )    ,       
.   ,         
,            ,  
  .      ,     
   -- ..      (    
)       ,   ,    
.

              (overloaded)  , 
    C++.           
 (      ).

       ,       
,        . ( 
   "-").  
  #' <  >.      
   ,   ,   
. :

     int (float a, b, c) t_func = #{ return :int (a * b * c) };
t_func (2, 3, 4) !! 24 (int)

       

              ,       
  .     ,
   ,   -     
.

      ,            typedef  C,
   . ,     ,
         (type < >),  ,  
,     . :

     !! flt --  float,
!! pflt --   float
!! ppflt --     float
float type flt, ^ type pflt, ^^ type ppflt

        type  ,      
   %'  (          ).     ,  
      ,    
  type (  %'):

     %flt x, y, z; !! .. float x, y, z
%pflt p1, p2; !! .. float ^ {p1, p2}
%ppft pp1, pp2, pp3 !! .. float ^^ {pp1, pp2, pp3}

              --   ,   
     .           ,  
   ,    type, 
 .

        --        ,
          
 ,    ,  .  
 :

     %(2 * 2) xx, yy, zz; !! .. u_int xx, yy, zz
%(10 < 20) pp, qq; !! .. bool pp, qq
%("text" []) cc !! .. char cc

           (        , 
    ) ,    , 
       .  , , 
    (    !)   --   
  ( ) .       
    .  ,           
  (    --      )      
 , ..       .
  ,      :

     !!  v_type --  :
%(v_type []) %v_type_elem; !! v_type_elem --    v_type
!!  p_type --  :
%(p_type ^) %p_type_ref; !! p_type_ref --  ,
                      !!
  p_type
!!  f_type --  :
%(f_type ()) %f_type_result !! f_type_result --   ,
                      !!
 f_type  

               --    
(let-).   ,            ,   
  #define    C/C++,  ..       
     .        .  
 C- --    ,  let- --
     ,    let-     
  --      .  
   :

     let NAME1 =' EXPR1 (,' NAME2 =' EXPR2) ...

                 NAME#    
      EXPR#.              ,
            .
    ,      EXPR          
,       :     ,     ,
    EXPR,    .     
    ,       : 
           ,   
   . :

     int value; !!  
let v1 = value; !! v1 --  value
{ float value; !!  value  
value; !! (float value)
v1 !! (  -- int value)
}

     ,  EXPR  L-,  NAME --  L-.
       , 
   :     (  
-,      )  
        , ,   
:

     %err_no (%string FileName) #SystemOpenFile;
let SysOpen = SystemOpenFile !! 

           conceal --   "" .
 ,       (,
)             (  
,   ),           
 conceal:

     conceal NAME (,' NAME1) ...

       conceal              
 (       , 
).     ,     conceal  NAME        let
NAME=<nothing>.  ,  conceal    
      (,   -  
      ), , ,  ,  
    .

        

                
  (    ,     
).       . ,  
       ,         
.     --    ( ,
     ,  ).            
  ,    ,  ..     ,
     (;')      ("{}").
          
       . ,      
  :    --   
 (        ).   
           ,  ..    
  ,       (, ,
    ).          
   LABEL :',    break, continue  goto  
 .    .

       (assert)  :

     assert CND

        :   CND (  bool).   
,         ,            
  AssertException.      
""      .

      ,    (if/unless),   
:

     (if P_CND | unless N_CND) BLOCK
[else E_STMT]

      (  if-)    P_CND     ( unless-)
  N_CND  ,     BLOCK.    , 
    else,     E_STMT.
,        --     ,  
   (     " else").
,     (  C)   (, ,
      ).    else      
(,    if/unless). ,    if    unless 
,      --   .

          ,       (
 )  .     :

     [for I_EXPR]
(while P_CND_PRE | until N_CND_PRE | loop)
[do R_EXPR]
BLOCK
[while P_CND_POST | until N_CND_POST]

           ,        
.      for        --
 I_EXPR,           
   .            ,     
,     .  (   while)
P_CND_PRE    (  until) N_CND_PRE  ,    
.          loop,  .
        BLOCK,        .
    do   :   R_STMT 
      . ,    
:   (   while)  P_CND_POST     (   until)
N_CND_POST  ,    .     
 -   -- , -,  . 
        --     ,  
,              .  
,      I_EXPR     ,  
          (..      
   ).   for   do    --   
   ,          
   . ,         i,  
  () 0  () N;    :

     for u_int i = 0 while i < N do ++ i { !(   )! }

          - . 
     break:

     break [LABEL]

          ,   LABEL
(        ,     ).    
LABEL ,      ,  
break.   continue:

     continue [LABEL]

              LABEL  (,    
,      )           
(     ,   ).

           goto:

     goto [LABEL]

       ,    LABEL.  
      ,
    .  goto   ,   
   --      .

               
return:

     return [EXPR]

                
      EXPR (  ).  EXPR ,
   -- void.

     ,     with,     
    .

       

       --    -  .      
  --     , 
  ,   .

                   ,  
        .     
 :

     class CLASS_NAME [:' SUPERCLASS_NAME]
     {
     CLASS_DECLS
     }
[instate INSTATE_LIST]
[destructor DESTRUCTOR_BODY]

          .  ,  
            (CLASS_NAME). 
      ,             
 (  SUPERCLASS_NAME).      
     ,    CLASS_DECLS.  
               (  
  ,    ).       
  ,   .

      ,        , 
    .   ,      
         .    
          static    shared,  
  ,  ..,      ,  
 ,     ,    
    .    static  shared   ,
 static-   (   
   ),    shared  ,  
  ,   .

                    
(private)      (protected)  .       C++,   
,   private-,    
,       protected-  --            
.     , ..  
 - .

            . , 
 ,    ,     (    
 )    type  %' (  class).

            (  )    
  .        
 .          
 CLASS_NAME^    shared,  ,    
,  nil.       
    .     
 (, CLASS_NAME),    :      . 
                
  this:

     CLASS_NAME; !!    CLASS_NAME
this !!    

                 .'  ().
          , 
  (  ) --     ( 
   L-   ).     C++ 
,      ,  ,        
 ,        . 
            :        .
          ,         
              (..   
   ,  ,         ).
   --  ,    (      
)      -    
.      ,  
 :

     !!     
class VECTOR { float x, y, z };

%VECTOR vec1, vec2; !!    VECTOR
vec1.x; !! x- vec1
vec2.(x + y + z); !!   vec2
vec1.(x*x + y*y + z*z) !!   vec1

         --       ( ,
 ),     ,   
     (..       ).
  ,            
  ::' ()  C++:

     VECTOR.x !! x-   VECTOR
this.x !!       VECTOR

                    
 --   with:

     with OBJ_EXPR BLOCK

            :       BLOCK 
  ,    OBJ_EXPR (),   OBJ_EXPR  
     ().  :

     with vec1 { x = y = z = 0f }; !!   vec1
with VECTOR { x = y = z = 0f } !!      VECTOR

              --  
,      .    C++  Java 
,                
  ,    . ,   
            .
,   ,     , 
       (   
  ).      , ,    
  ,       .
      VECTOR:

     !!     `a`
void (float a) scale_VECTOR
{ with VECTOR { x *= a; y *= a; z *= a } }

       "-" scale_VECTOR    
 ,   ,     :

     vec2.Scale_VECTOR (1.5) !!  vec2  1.5
with vec2 { Scale_VECTOR (1.5) } !!  ,   
Scale_VECTOR (2f) !!    VECTOR  2

      ,         
,        (      ).
              
.          :
          
  .      : 
     ,       ;  
   .      ; 
  C++      "".

      ,         
        .        
     ,              
.     .

               --  
    .    ,     
      C  C++,    
.

             
:

     #' (' <COMP_LIST> )'

      COMP_LIST --       . 
          ,      
     .   :   
    ,      .  
    ,    .     
   .  ,     , 
     (    ,      
 ),     . ,
,       
 :  VAR = #( LIST )     VAR  ( LIST
).     VECTOR:

     %VECTOR null = #(0f, 0f, 0f); !!  
%VECTOR null (0f, 0f, 0f) !! ( , )
%VECTOR null (x: 0f, y: 0f, z: 0f) !! ( ,  )
!!  -
%VECTOR PX (1f, 0f, 0f), PY (0f, 1f, 0f), PZ (0f, 0f, 1f)
%VECTOR NX (-1f, 0f, 0f), NY (0f, -1f, 0f), NZ (0f, 0f, -1f)

          ,     VECTOR, 
           .
,          -"  ",     
 ,          .
        ,   
  -- .

                   .
       ,          ,      
      constructor  (   ,
      ).    C++   Java, 
     --  :       
  ,      (     
    ).  ,      VECTOR    
 :

     !!    
!! (len -- , phi -- , theta -- )
onstructor (float len, phi, theta) polar
{ x = len * sin(phi) * cos(theta), y  = len * cos(phi) * cos(theta), z = len
* sin(theta) }

             :

     onstructor (float len, phi, theta) polar :
(len *  sin(phi) * cos(theta), len * cos(phi) * cos(theta), len * sin(theta)
) {}

            --     
   ,       
.              ,       
,      -       
   (,           ),    
-    --      
      .   ,     polar
,    :

     %VECTOR anyvec = :polar (200f, PI/4f, PI/6f)

             :    
   ,          
 .

        C++,     .   
     ,      
(     .'). :

     VECTOR (0.5, 0.3, -0.7) !!  
VECTOR.polar (10.0, 2f*PI, PI/2f) !!  

                    ,  
 ,     .

       ,      
  ,       . 
--       ,     ,      
      .       
 .         ,   
     ,     .  ,
     ,          .
,    :        
  ,        -      
    (,           
),       .

           ,   . 
 ,    ,        
    ,       ,     .
          , 
          .
             (    !)
 .    let    conceal    
   ,     
  .

        ,        ,     
  virtual.   ,     
  , ..       
  .       ..
  :      ,   
        ,       
    ,    ,     
       ,   
.     .    
         instate,  
 .           :
    virtual-  .    
instate          ;  
     .

           ,   
  . ,    --  ,
       . ,      C++,
        -    
  .

     ,         ,        
  (  ).   --  ,
              (,  ,  
    )            
   -.      
    abstract  class.   
    ,     
    ,          "
".

      ,    ,    
  -    (    
).

     !!   ( )
abstract Figure {
     !!   ...

     !! --  :
     float () virtual perimeter;
     !! --  :
     float () virtual area;
     };

     !! 
class Point : Figure {
} instate #perimeter { return 0f }, #area { return 0f };

     ! ( L)
class Line : Figure {
float L !! 
} instate #perimeter { return L }, #area { return 0f };

     !!  (  S)
class Square : Figure {
float S !! 
} instate #perimeter { return 4 * S }, #area { return S * S };

     !!  (  A, B)
class Rectangle : Figure {
float A, B
} instate #perimeter { return 2 * (A + B) }, #area { return A * B };

     !!  (  R)
class Circle : Figure {
float R
} instate #perimeter { return 2 * PI * R }, #area { return PI * R * R };

             ,   
      -   .          
         fig_vec:

     %Figure @ []@ fig_vec; !!      
float total_area = 0f; !!  
for u_int i = 0 while i <> fig_vec# do ++ i
     { total_area += fig_vec [i].area () }

         ,     --     
       .          
          
 .   :

     CLASS qual OBJ_PTR_EXPR

          OBJ_PTR_EXPR (   
)          CLASS   (      
OBJ_PTR_EXPR^).     CLASS^:   ,  
   ,     
CLASS,       ,       
  nil.          
,      .

     %Figure ^fig_ptr; !!   
%Rectangle some_rect (10f, 20f); !!  10 * 20
%Circle some_circ (50f); !!   50

fig_ptr = some_rect@; !! fig_ptr   
Rectangle qual fig_ptr; !!    some_rect
Circle qual fig_ptr; !!  nil

fig_ptr = some_circ@; !! fig_ptr   
Rectangle qual fig_ptr; !!  nil
Circle qual fig_ptr; !!    some_circ

         qual        
 dynamic_cast     C++.

      

          C++,         
.    ,            
:       ,   
 (,     - ,      
). ,          
,              .
   --         ,     
     ,    
              .   (,      
  , , .)

                 
opdef:

     opdef OP_DEF1 =' EXPR1 (,' OP_DEF2 =' EXPR2) ...

             ,        
.    OPDEF --   ,    
 ,   -     
. (        
,   ,        
).

        EXPR      
OPDEF.      EXPR         
(<1>),  (<2>)...,     ,   
.. :

     opdef VECTOR + VECTOR = VECTOR.add (<1>, <2>)

              +'     
 VECTOR.              add
(        VECTOR)       
 .

         --   ,
                         
let-.   ,         ,      
.    --    :   
          ,  
.       
,         opdef-        
,        
(, -,  ).

     ,  ,      ,        
,        
 opdef-.    .  ( , ,
    .)

             .      
   String,   ,   
 :

     class String {

!! (...)

!!   
u_int () #length;
!!  ()  head & tail
%String (%String head, tail) #concat;
!!  ( n )  str
%String (%String str; u_int n) #repl;
!!   str ( from  to)
%String (%String str; u_int from, to) #substr;

!! ...
}

          ,        
.

     !!   ...
let Str = String;
!! #'   :
opdef Str# = (<1>).len ();
      !! +'  :
opdef Str + Str = Str.concat ((<1>), (<2>));
!! *'  :
opdef Str * u_int = Str.repl ((<1>), (<2>));
opdef u_int * Str = Str.repl ((<2>), (<1>));
!!   
opdef Str [u_int..u_int] = Str.substr (<1>, <2>, <3>);

          :

     Str("ABBA")#; !! 4
Str("Hello, ") + Str("world!"); !! Str("Hello, world!")
Str("A") * 5; !! Str("AAAAA")
3 * Str("Ha ") + Str("!"); !! Str("Ha Ha Ha !")
Str("Main program entry") [5..12]; !! Str("program")

          ,              
   .   
 (    )        
  -,         .  
     --  .
,       VECTOR        
(OFile --   ):

     opdef OFile <: VECTOR =
(<1>)  <:  (  <:  (<2>).x <: ,'  <: (<2>).y
<: ,' <: (<2>).z <: )'

     ,      -   
         (  ),  
      ,    .   
    :         , 
        .        
:

     opdef OFile <: VECTOR =
(<2>).((<1>) <: ( <: x <: ,' <: y <: ,' <:
z <: )')

     ,  -  ,          
   ,                
 .         
 VECTOR,  ,   , .

       .
.

                ,   
   -    . ,   
           : , 
  -         ,    ,
   --      
.

         ,    
     ,     .        
     .    
        ( 
        )    (  
 ,   ).

         (,  , ,
     )          .  
        ,  :

     export { DECLARATION_LIST }

               ,      
  ()      .        ,
      DECLARATION_LIST,    
.          ,       
 ,  :

     import MODULE { STMT_LIST }

             ,        
:        ,  ,  
.  MODULE --    ,   .   
  ,    ,    
()      ( MODULE    
  ). STMT_LIST --   ,  
  ,   MODULE.   ,  
    import,     
 .

        / --      ,
     .  ,     
        ,  , 
  ,    .  , 
         ()   
()  .         
        ;    (
  )  .

     ,            
  -- :

     pragma PRAGMA_STR

       PRAGMA_STR      ,  
              
.   ,              
,  ,      ,   
,    ..

          

        --                    
.           
           --   
,      "" .     
   .

     ,                  
let-    .          
 #define C- -- ,    , 
,  opdef',        
 .  ,    
            
.

          ,  ,       
-,     (template)       ,
     C++. ,    ,
       .

              -       ,
  switch/case   C  C++,         .
  ,           ,  
  .  ,      
      "".

     ,              
  (enum),     ,   C.

              .      
   ,   C++?   
         .       :     
     (        ),   
       -  (
           Java),             
-, , ,   - .

           ,     
  .              
        ,      C++  Java.   
            (,
  ,  , ,   
  ).  ,     
"" ,              --
"  ",           
  .            
 .

     ,        ,    
      ,   --      .
,   (   , ,    )
         --   
     .

     ,      --  , 
 ,     .

     

            ,         
   -,             
 .

     !!
!!  : "complex.xrn"
!!   `complex`:
!!   ()
!!

!!   (   ):
double (double x, y) #atan2; !!  
double (double x, y) #hypot; !! 
double (double x) #sqrt; !!  

     class complex {
     !!  
     double Re, Im; !! (real, imag)

     !! [   %complex]
     %complex (%complex op1) %opUnary;

     %opUnary #conj; !! 
     %opUnary #neg; !! 
     %opUnary #sqrt; !!  

     !! [   %complex]
     %complex (%complex op1, op2) %opBinary;

     %opBinary #add; !! 
     %opBinary #sub; !! 
     %opBinary #mul; !! 
     %opBinary #div; !! 

     !!   
     bool () is_zero { return Re -- 0f && Im -- 0f };

     !! [  %complex]
     bool (%complex op1, op2) %opCompare;

     !! ( ):
     %opCompare eq { return op1.Re -- op2.Re && op1.Im -- op2.Im };
     !! ( ):
     %opCompare ne { return op1.Re <> op2.Re || op1.Im <> op2.Im
};

     !! 
     double (%complex op) mod { return hypot (op.Re, op.Im) };
     !! 
     double (%complex op) arg { return atan2 (op.Re, op.Im) };
     };

     !!   

!!   op1
#complex.conj { return #(op1.Re, - op1.Im) };

!!  op1
#complex.neg { return #(- op1.Re, - op1.Im) };

!!  op1  op2
#complex.add { return #(op1.Re + op2.Re, op1.Im + op2.Im) };

!!  op1  op2
#complex.sub { return #(op1.Re - op2.Re, op1.Im - op2.Im) };

!!  op1  op2
#complex.mul {
     return #(op1.Re * op2.Re - op1.Im * op2.Im,
     op1.Im * op2.Re + op1.Re * op2.Im)
     };

!!  op1  op2
#complex.div {
     !! (   )
     assert ~op2.is_zero ();

     double denom = op2.Re * op2.Re + op2.Im * op2.Im;
     return # ((op1.Re * op2.Re + op1.Im * op2.Im) / denom,
     - (op1.Re * op2.Im + op2.Re * op1.Im) / denom)
     };

let g_sqrt = sqrt; !! (  `sqrt`)

!!    op1 (  )
#complex.sqrt {
     double norm = complex.mod (op1);
     return #(g_sqrt ((norm + op1.Re) / 2f), g_sqrt ((norm - op1.Re) / 2f))
     };

     !!
!!     complex
!!

!!  '-'  
opdef -complex = complex.neg ((<1>));
!!  '~'  
opdef ~complex = complex.conj ((<1>));

!!  '+'  
opdef complex + complex = complex.add ((<1>), (<2>));
!!  '-'  
opdef complex - complex = complex.sub ((<1>), (<2>));
!!  '*'  
opdef complex * complex = complex.mul ((<1>), (<2>));
!!  '/'  
opdef complex / complex = complex.div ((<1>), (<2>));






Last-modified: Sun, 08 Sep 2002 05:41:28 GMT
: