, 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,
.
,