. :
: 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.
, . ,
(tiny → short
→ int → long), , (float → double
→ quad) (char → w_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)
.
.
, ,
: